-
Notifications
You must be signed in to change notification settings - Fork 447
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
Whisper onnxruntime exception on Android #633
Comments
Could you describe how you created the APK? Does it work with the APK from us? |
No it crashes the same way. You can reproduce this error with |
Just want to re-check that you are using sherpa-onnx 1.9.11, right? |
Yes I use version 1.9.11, but I've also tried with the last commit from master #5dc2eaf |
Btw, this warning is printed sometime before this exception happened: |
Could you tell us whether you are using our apk, or write your own? Also, are you using the code from #617? Please give us more information. |
Yes I use your example project SherpaOnnx2Pass with v1.9.11, so code from #617 is used. |
How long is this audio? Are there pauses? If yes, how long is the pause? |
Audio used is a 5 minutes conversation, with pauses. |
Does it cause a crash or the APP can continue work? |
No the app doesn't crash. It's an exception printed in the logs |
How many exceptions did you see? One or many? |
There can be several per session |
Does it affect the final recognition result? These logs are only available in logcat. |
Yes because when this error occurs the call to decode may freeze for a long time (~10 to 30 seconds) and no results will be returned. |
It's seams this happens when this condition offline-whisper-greedy-search-decoder.cc#L148 is not reached:
Then |
Could you use a larger tail padding? You can always use |
With a padding of |
Hello, we have been experiencing the same errors described above with sherpa-onnx 1.9.23 in Ubuntu environment. We have observed the errors at variable frequency, 1-10 cases per 1000 utterances. They occur with various models (base/small/medium/large, int8/float), but mostly with English monolingual models. A part of problematic audio files seem to cause a timeout and do not get transcribed on the Huggingface API available under https://huggingface.co/spaces/k2-fsa/automatic-speech-recognition either. Monitoring the decoding (logging tokens in the for cycle around line 100 looping over text_ctx) we observe that repetitive patterns occur and the EoT is never reached until the cycle runs out. Sometimes the speaker makes indeed repetitions (like repeating a word many times, 5 times or above) sometimes there is no evident cause of getting stuck in a repetitive loop of tokens without reaching EoT. Increasing the tail paddings helped only a very little for us. Through monitoring the predicted_tokens buffer, we attempted to detect if repetitions start to occur and force an EoT after a critical number of repetitions have occured. This efficiently prevented getting stuck and endig up in an empty transcript with all of our problem utterances. We were trying resetting instead of stopping, but the majority of utterances got stuck again and just some finished with success. The drawback of forcing EoT is that the tail of the audio will not be transcribed. But it helps at least preventing spending a lot of time in the for loop. I am wondering if a more advanced fix is available for the problem? If there is an interest to review this small code extension, let me know, I am happy to create a PR on a fork or just copy-paste the changes since they are not abundant. Thank you! |
The problem is introduced by our modification to whisper. The original whisper needs 30 seconds of input. If the input is less than 30, then it is padded to 30, which means it has enough padding to detect the EoT. In the current change, we remove the 30 seconds constraint and if the padding is small, then it may not abe able to detect the EoT. As described in #633 (comment), restore the original behavior by padding the input to 30 seconds can fix the issue, at the cost of extra computations for extra paddings. |
Actually, our problem is that despite using a padding of 30000, we are still getting invalid shape error and an empty transcript. I can see this utterance gets stuck in repeating tokens 11 and 607 alternately until n_text_ctx is reached with no EoT at the end at all. |
Can the official whisper implementation decode your |
Yes, it can. (I have also double checked that sherpa-onnx versions match , I mean I am using the same version for decoding which was used during export.) |
Would you mind sharing.the wav file with.us? |
Unfortunately I can't, I am bound by severe data privacy constraints. It may however be of importance, that the majority of the utterances I deal with contain non-native English speech (the whisper model is not fine-tuned). I have so far a couple of problem utterances, as I wrote earlier, some indeed contain repetitions where decoding gets stuck at the repeated word. Others seem to be quite standard utterances. |
Hi @csukuangfj , I have a new sample producing the same error, I am able to share it with you by discarding third party public. Please let me know if you can accept the file and if so, the way I could send it to you. Thank you. |
Thanks! Could you send the test wave to csukuangfj at gmail dot com |
Description
After invoking Whisper recognizer on Android multiple times consecutively, the following error is encountered:
Reproduction Steps:
Environment Details:
The text was updated successfully, but these errors were encountered: