alphacep / vosk-api

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

Java example is Missing or is not too easy to find #1621

Closed JoaoPedroFortes closed 3 months ago

JoaoPedroFortes commented 3 months ago

I'm trying to implement a solution using Java, but the only example that I found was that: https://github.com/linto-ai/linto-vosk-api/blob/6d60a20a237bc5df0ebbf5689243360a4334aab7/java/demo/src/main/java/org/vosk/demo/DecoderDemo.java

I'm trying to use VoiceReconizer with a Portuguese model, but until now, I only recovered a few words and don't know how to configure the recognizer to get a better accuracy.

I don't understood how to use the "setPartialWords", "setGrammar" or "setMaxAlternatives" methods to get a better result.

Thanks in advance

nshmyrev commented 3 months ago

Hi.

Our demo is here, not on Linto

https://github.com/alphacep/vosk-api/blob/master/java/demo/src/main/java/org/vosk/demo/DecoderDemo.java

As for few words, the biggest source of trouble is wrong file format. Make sure your audio is 16khz 16bit mono.

If you still have troubles with the accuracy share the problematic file.

JoaoPedroFortes commented 3 months ago

Hi, Nickolay.

Thanks for reply. I'll check my record method and try again.

nshmyrev commented 3 months ago

Let us know how it goes.

JoaoPedroFortes commented 3 months ago

I changed my audioFormat setting to private static final AudioFormat FORMAT = new AudioFormat(16000.0F, 16, 1, true, false);

and now it's working

Thank you very much