Alexei
Alexei

Reputation: 407

Python doesn't find model in folder at Model(model_name="models/model-en-0.2) If Model(model_name="model-en-0.2)is writen then it works.How to fix it?

Python doesn't find the vosk model in the folder at Model(model_name="libs/models/vosk-model-small-en-0.22").

from vosk import Model, KaldiRecognizer
FRAME_RATE = 16000
CHANNELS=1

model = Model(model_name="libs/models/vosk-model-small-en-0.22") #The model is in this folder.
rec = KaldiRecognizer(model, FRAME_RATE)
rec.SetWords(True)

this cell throws an error: "Exception: model name libs/models/vosk-model-small-en-0.22 does not exist"

If you put the "vosk-model-small-en-0.22" model folder on the same level as the python script and write:

FRAME_RATE = 16000
CHANNELS=1

model = Model(model_name="vosk-model-small-en-0.22")
rec = KaldiRecognizer(model, FRAME_RATE)
rec.SetWords(True)

then everything works.

I will use several models for different languages, it is convenient for me that they lie in the model / libs. How do I write the address in model_name so that everything works?

Upvotes: 1

Views: 2792

Answers (3)

Munesu Dube
Munesu Dube

Reputation: 1

If you use the model_name named argument, Vosk will look for the model at C:\Users\User\.cache\vosk\<model_name> (or some equivalent for Linux).

To use a different folder, just pass in the folder path as a string, like this:

model = Model("models/vosk-model-small-en-0.22")

You can also use a full path, for example:

model = Model("C:/Users/User/Documents/models/vosk-model-small-en-0.22")

Note: If you use a path with backslashes instead, remember to escape them, e.g.:

model = Model("C:\\Users\\User\\Documents\\models\\vosk-model-small-en-0.22")

Upvotes: 0

Chandan Kumar Yadav
Chandan Kumar Yadav

Reputation: 51

Let me clarify the Alexei answer a little bit more.

Your model is getting stored in the .cache folder which you can find in the user folder of C:\ drive.

Model file path is created at C:\Users\User.cache\vosk\vosk-model-small-en-0.22

enter image description here

By default, it will store smaller version of your model which was trained on smaller dataset. But if you wish to use the model trained on the larger dataset you have to replace all the files inside the \vosk-model-small-en-0.22 folder with the files from the larger trained model. Before pasting the files, you have to unzip the larger model which you wish to replace with. You can have models of different languages and all can be found in the .cache folder of C:\ Drive.

enter image description here

Upvotes: 1

Alexei
Alexei

Reputation: 407

I found out that the model should be located at C:\Users \ User \ .cache\vosk\vosk-model-en-0.22

Upvotes: 0

Related Questions