Skip to content
Advertisement

Where should i put Model files of VOSK speech recognition in java? ERROR (VoskAPI:Model():model.cc:122)

I have tried to use VOSK but get this error:

ERROR (VoskAPI:Model():model.cc:122) Folder 'fa' does not contain model files. Make sure you specified the model path properly in Model constructor. If you are not sure about relative path, use absolute path specification.
2021-10-24 11:54:00.306 ERROR 17856 --- [nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.Error: Invalid memory access] with root cause

Advertisement

Answer

After downloading the language model you want from https://alphacephei.com/vosk/models you have to decompress the files inside the compressed folder.

Example: The spanish model downloads the compressed folder “vosk-model-small-es-0.22”, you have to put the files and folders inside “vosk-model-small-es-0.22” in the path you are passing to the Model constructor.

Model constructor accepts absolute paths:

try (Model model = new Model("D:\models\spanish")
{
    ... your code here...
}

I made some testing, and Vosk recognized my audios if they were 16KHz mono wav (I used audacity for the conversion).

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement