vosk-api icon indicating copy to clipboard operation
vosk-api copied to clipboard

An option to FinalResult which would skip all the deallocations

Open FredSRichardson opened this issue 2 years ago • 4 comments

This is really just a feature suggestion to add batch mode segment based decoding to the Recognizer.

Implementing this myself, I ran into the following problems:

  • When you call FinalResults() to get the final results the call deallocates a bunch of things including the decoder which has to be reinitialized now between each segment adding unnecessary overhead.
  • There is no way to call InitState() which means word offset times are adjust by however much data you have decoded up to that point.

I would suggest adding an option to FinalResult() which would skip all the deallocations and an option to Result() and FinalResult() which does not adjust start/end times to support batch mode processing. It would then be up to the user to periodically reallocate the decoder (for example to avoid memory leaks etc.).

FredSRichardson avatar Jun 22 '22 18:06 FredSRichardson

If you want to reallocate the decoder you simply reallocate the decoder. I don't see any issue. There is no overhead, decoder object is lightweight.

nshmyrev avatar Jun 22 '22 20:06 nshmyrev

Yeah, that's not what I saw. In Python, I added a step deallocating the decoder and reallocating between each segment and this ran significantly slower.

FredSRichardson avatar Jun 22 '22 21:06 FredSRichardson

And if you just feed data after FinalResult? It should also work.

nshmyrev avatar Jun 22 '22 22:06 nshmyrev

Yes, this works, bit you are taking an unecessary hit deallocating and reallocating the decoder. Also you have a time offset added to each word start time. It's just not ideal for segment based processing though it is great for streaming processing.

On Wed, Jun 22, 2022, 6:12 PM Nickolay V. Shmyrev @.***> wrote:

And if you just feed data after FinalResult? It should also work.

— Reply to this email directly, view it on GitHub https://github.com/alphacep/vosk-api/issues/1037#issuecomment-1163661266, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPMHIMWZHF4N6KIQVKBCRLVQOFWNANCNFSM5ZRHEZHA . You are receiving this because you authored the thread.Message ID: @.***>

FredSRichardson avatar Jun 23 '22 02:06 FredSRichardson