Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert stereo to mono in read_audio_file #292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SRavit1
Copy link

@SRavit1 SRavit1 commented Jun 7, 2020

When trying to train an HMM with your library, I got an error in ShortTermFeatures.py function energy_entropy. It seems that you were assuming that the audio is mono, not stereo, in the line below.

ShortTermFeatures.py, Line 35
frame_length = len(frame)

If the audio is stereo, then frame_length is not equal to the total number of elements in frame, as there are two channels. For example frame_length is 2400 but the frame shape is (2400, 2).

Here is why that was problematic. When I tried running my stereo .wav file through the HMM program, it failed at the following line.

ShortTermFeatures.py, Line 35
sub_wins = frame.reshape(sub_win_len, n_short_blocks, order='F').copy()

To fix this, I changed function read_audio_file audioBasicIO.py, so that it converts stereo to mono by taking the mean of the two channels. This fixed my problem for me, and I hope it will for other people too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants