Vosk api: allow selecting different models and automatic model download #657
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
I added/changed two parameters in the recognize_vosk function, which i believe to be useful.
Firstly, I added a model parameter to allow to select a model based on a model directory. This was previously hard coded to one directory named 'model', making it impossible to easily switch models respectively languages.
Secondly, I noticed that Vosk-api is actually able to download models by itself, based on a given language code. So I implemented this as another parameter 'language'. Previously there was a default language parameter provided in the function, but it was never used.
I implemented it so that the model parameter has precedence over the language parameter, but it defaults to an empty string (False). So that by default the language model is downloaded automatically, because i believe this to be more convenient for the user. However I'm aware that this breaks the previous behavior and may break a user implementation if they want to use a very specific model that they already downloaded (for example one of the larger models). If you think this is a problem i could try to change that.
Also see the updated README in the commit.
Please let me know what you think
Thanks
ps.: if this gets merged i would also update the documentation and maybe write some tests for vosk, which i think are still missing.
pss: also it may be good to actually change to return value of the vosk function to make it more in line with the other functions, since i think this is currently returning a json string, instead of a simple string like the others. (Edit: mentioned here aswell: #592 )
Edit: also now i found this similar pull request #607 adding a model path