alphacep / vosk-server

WebSocket, gRPC and WebRTC speech recognition server based on Vosk and Kaldi libraries
Apache License 2.0
882 stars 243 forks source link

Java example doesn't send config on stream start #166

Closed xuanxuan000 closed 2 years ago

xuanxuan000 commented 2 years ago

Hello, you may have forgotten to send WAV information in the Java example, such as:
ws.sendText("{ \"config\" : { \"sample_rate\" : 16000 } }");

nshmyrev commented 2 years ago

Configuration is optional, it is not necessary to send it

xuanxuan000 commented 2 years ago

In Chinese recognition services, if no configuration is sent, then I will get:

    {
      "result" : [{
          "conf" : 0.996978,
          "end" : 2.722010,
          "start" : 0.210000,
          "word" : "[FIL]"
        }],
      "text" : "[FIL]"
    }

If I sent the configuration, I will get the correct result:

I/System.out: }
    {
      "result" : [{
          "conf" : 0.993129,
          "end" : 0.840000,
          "start" : 0.090000,
          "word" : "今天"
        }, {
          "conf" : 0.993129,
I/System.out:       "end" : 1.350000,
          "start" : 0.840000,
          "word" : "下雪"
        }],
      "text" : "今天 下雪"
    }

I used the same voice Only in Chinese, I have not used other services

nshmyrev commented 2 years ago

Default sample rate is 8khz, to switch to 16khz you send config. If you want to decode 8khz, you send straight away.

xuanxuan000 commented 2 years ago

I see. Thank you very much for your help.