alphacep / vosk-api

Offline speech recognition API for Android, iOS, Raspberry Pi and servers with Python, Java, C# and Node
Apache License 2.0
7.57k stars 1.06k forks source link

Reloading vosk model for each transcription #1313

Open nurgul-ths opened 1 year ago

nurgul-ths commented 1 year ago

Hello!

Could you please help with the following question: Is it necessary to reload the vosk object every time? I am hoping to save up a lot of time if I can load the model just once. I am using this model: vosk-model-small-en-us-0.15, my code is running in C on Linux (Ubuntu 18.04).

Thank you very much!

nshmyrev commented 1 year ago

You can load model just once.

nurgul-ths commented 1 year ago

Thank you for your reply @nshmyrev.

Unfortunately, I am still confused about this. I am calling this file https://github.com/alphacep/vosk-api/blob/master/c/test_vosk.c after creating a wav file, and I believe lines 9-10 (in the file test_vosk.c) reload the model, which adds around 20 seconds to the waiting time. Is it possible to cache the model somehow or am I doing something wrong? Please let me know if I should provide more details, I am new to Vosk and I would really appreciate it if you could elaborate more on how the models are loaded once.

Thank you very much!

nshmyrev commented 1 year ago

Yes, you can keep model pointer between recognitions, no need to initialize it again and again.