bjbschmitt / AMFM_decompy

Package containing the tools necessary for decomposing a speech signal into its modulated components (also known as AM-FM decomposition). Includes the algorithms of the QHM family and the YAAPT pitch tracker.
MIT License
85 stars 18 forks source link

Fixed a bug causing "Mean of empty slice" warnings during pYAAPT execution #7

Closed omaraltayyan closed 6 years ago

omaraltayyan commented 6 years ago

the bug is discussed in #6 (comments 9 through 12) and this code seems to fix it, i ran the tests after the modifications and everything seems to work well.

omaraltayyan commented 6 years ago

hi @bjbschmitt

i made a fix for the bug we discussed in #6 earlier, hope you find it good enough.

omaraltayyan commented 6 years ago

@bjbschmitt I've just tested the algorithm on my entire dataset, which is about 14000 files totaling 56 hours, and there weren't any errors thrown as before.

bjbschmitt commented 6 years ago

Hi @omaraltayyan I ran your script and I was finally able to reproduce the bug. It seems that the issue occurs when you create a SignalObj instance using a PCM signal as input data (the output of the scipy.io.wav.read() function is PCM).

Your solution works fine, but there is a problem: if you want now to create a SignalObj instance using an input float signal (for example, an output coming from another process or source), the pcm2float function will raise an error. So, I added an extra "if" before pcm2float in order to check whether the signal is PCM or float. By doing this, the SignalObj instances can be created with either PCM and float inputs.

Here is the script that you sent me with a small modification (line 19) empty_slice.py.zip . If you run it using your solution, it raises the error and you won't be able to use input float signals.

I'll commit then your code, make some modifications and update the package soon. Thanks again for your help!

omaraltayyan commented 6 years ago

@bjbschmitt i checked your modifications and i understand the problem

Thanks again.

bjbschmitt commented 6 years ago

Ok cool, I guess that the old commentaries in the code were not very good anyway, so I'm modifying them to make things more clearer.

omaraltayyan commented 6 years ago

Ok great Thanks again and good luck with your work.