-
Notifications
You must be signed in to change notification settings - Fork 98
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
pesq calculation terminated in the middle without no error message #12
Comments
|
Is there a plan to merge this or add a similar feature? |
@samedii created this PR some months ago, where we've discussed some alternative implementations of the same fix with @ludlows, as they had a problem with the semantics and performance implications of exception throwing. I think in the end @ludlows decided to prototype a solution in a branch, but they might not have had the time to do it. I can add that one way you can prevent this error from happening is to check if your buffer is not filled with zeros. |
Thanks for all the discussions above. This project was created under the work of my Master Thesis. @Rafagd you can pr your zero-checking code to master branch so that I can update this change to PyPi. just let me know if you have any concerns. |
I am not sure, what @Rafagd meant with zero checking, but I would prefer to be as close as possible to the original implementation. |
I agree about raising exception instead of outputting some NaN or zero. |
I meant to check the buffer for "silent moments", as this may cause the program to crash due to no utterances being found. I'm going to try to brew a best-of-both-worlds solution and I'll PR it in the next couple of days. Can't guarantee to deliver it fast, as I'm currently looking for a job and working part-time, so please don't depend on me! As a preview of what I'm thinking: I'm going to try to have multiple implementations of pesq(), so the default keeps the old behaviour, one with return values and one with exceptions. User can select which one they want on import. from pesq import pesq
from pesq import pesq_except as pesq
from pesq import pesq_retvals as pesq Or something like that. I'll also try to have that being an option directly in the pesq call as well: |
I assume no one relies on Is the logic of def pesq_retvals(...)
try:
return pesq_except(...)
except Exception:
return np.nan ? |
Well, currently on the C backend I'm already returning values, and then I'm checking the values in Cython to raise the correct exception. So it would be pretty much the other way around. Ie.: #current implementation
def pesq(...):
[.... STUFF ....]
cdef int res = pesq_measure(&ref_info, °_info, &err_info, &error_flag, &error_type);
if res == 1: #
raise PESQError("Invalid sampling frequency")
if res == 2:
raise PESQError("No utterances detected")
if error_flag!=0: # probably kept from past implementations.
return -1
return err_info.mapped_mos
#future implementation
def pesq_retvals(...):
[.... STUFF ....]
cdef int res = pesq_measure(&ref_info, °_info, &err_info, &error_flag, &error_type);
if res > 0:
return -res-1 # -2 for invalid, -3 for no utterances
if error_flag != 0:
return -1
return err_info.mapped_mos
def pesq_except(...):
cdef int res = pesq_retvals(....)
if res == 1: #
raise PESQError("Invalid sampling frequency")
if res == 2:
raise PESQError("No utterances detected")
return res I was thinking if it would be worth to inline the implementation to avoid the extra call. |
I think inline could be done, but it is not nessesary. PESQ is slow enough, that it does not matter. I feared that. I personally think that using
For the |
Well, that's mainly why I had implemented it the way I did back then. What I was proposing was just to offloading the decision to the user of the library. If you really want to bypass exceptions, here, have the c-style. Ps: Additionally, the original implementation already returns -1, in case some error happens.
The problem with NaN is that I couldn't express the reason why the code failed, but it is definitely doable.
I was planning on improving that bit, that code was a somewhat hastly done patch to fix a problem I was having back then. |
Double posting to link my PR, couldn't really resist to have a go at it. I have tested using the two files provided by this repository and it is working for them. Can someone test this code on a larger base to check it for validity? Also, I have checked the code and it was already using exception to validate arguments, so this whole discussion was kinda pointless. I have exposed the option to silently return values anyway, just in case someone is interested. Also, it would be nice if @samedii could replicate his changes from his PR on this one, just for the sake of keeping everyone's changed tagged to their names. |
As the users of this project ,@boeddeker and @mpariente, could you give opinions on this PR |
The code on |
Hi,
I installed python-pesq by " compile and install" procedure in read.me and successfully got the correct result with 'nb' for audio samples under audio directory. Now I used the pesq with 'nb' on my data (which are over 3 hours data each @ 8000Hz for ref and deg) but it terminated in the middle without either output or error message. Is there any limitation in size of data for ref and deg ?
Thank you in advance.
The text was updated successfully, but these errors were encountered: