Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognizer not ready, ignoring (Browser testing) #24

Closed
Kolumor opened this issue Dec 3, 2021 · 3 comments
Closed

Recognizer not ready, ignoring (Browser testing) #24

Kolumor opened this issue Dec 3, 2021 · 3 comments

Comments

@Kolumor
Copy link

Kolumor commented Dec 3, 2021

Hello team!

I am testing your software using apache2 on a virtual machine running a Ubuntu server on windows.
This is the index and I was trying to test the microphone input.
2
1
3 <script type="application/javascript" src="https://cdn.jsdelivr.net/npm/vosk-browser@0.0.5/dist/vosk.js"></script>
1
2
3
4
5 <script>
6 async function init() {
7 const model = await Vosk.createModel('https://ccoreilly.github.io/vosk-browser/models/vosk-model-small-en-us-0.15.tar.gz');
8
9 const recognizer = new model.KaldiRecognizer();
10 recognizer.on("result", (message) => {
11 console.log(Result: ${message.result.text});
12 });
13 recognizer.on("partialresult", (message) => {
14 console.log(Partial result: ${message.result.partial});
15 });
16
17 const mediaStream = await navigator.mediaDevices.getUserMedia({
18 video: false,
19 audio: {
20 echoCancellation: true,
21 noiseSuppression: true,
22 channelCount: 1,
23 sampleRate: 16000
24 },
25 });
26
27 const audioContext = new AudioContext();
28 const recognizerNode = audioContext.createScriptProcessor(4096, 1, 1)
29 recognizerNode.onaudioprocess = (event) => {
30 try {
31 recognizer.acceptWaveform(event.inputBuffer)
32 } catch (error) {
33 console.error('acceptWaveform failed', error)
34 }
35 }
36 const source = audioContext.createMediaStreamSource(mediaStream);
37 source.connect(recognizerNode);
38 }
39
40 window.onload = init;
41 </script>
42
43
44 Hola!
45
46
~

The result on console is the repetition of the following lines:

Recognizer (id: d6562c55-8db5-4918-9c65-fc0d1f061ff2): Sending audioChunk vosk.js:333:29
Recognizer (id: d6562c55-8db5-4918-9c65-fc0d1f061ff2): process audio chunk with sampleRate 192000 94bb588b-5609-4bb8-bd34-b6f9f1c4968e:269:25
Recognizer (id: d6562c55-8db5-4918-9c65-fc0d1f061ff2): process audio chunk with sampleRate 192000 94bb588b-5609-4bb8-bd34-b6f9f1c4968e:269:25
Recognizer not ready, ignoring 94bb588b-5609-4bb8-bd34-b6f9f1c4968e:271:29
Recognizer not ready, ignoring 94bb588b-5609-4bb8-bd34-b6f9f1c4968e:271:29
Recognizer (id: d6562c55-8db5-4918-9c65-fc0d1f061ff2): Sending audioChunk vosk.js:333:29
Recognizer (id: d6562c55-8db5-4918-9c65-fc0d1f061ff2): process audio chunk with sampleRate 192000 94bb588b-5609-4bb8-bd34-b6f9f1c4968e:269:25
Recognizer not ready, ignoring 94bb588b-5609-4bb8-bd34-b6f9f1c4968e:271:29
Recognizer not ready, ignoring 94bb588b-5609-4bb8-bd34-b6f9f1c4968e:271:29

Could you please help me?
Thanks in advance

@ccoreilly
Copy link
Owner

Service workers have a strict CORS policy which means you need to serve the model from the same domain via https, otherwise the browser will not allow downloading the model.

@Kolumor
Copy link
Author

Kolumor commented Dec 3, 2021

I understand, but we don´t think that is the problem since the model loads correctly and the browser even asks permission to use the mic, which also only works on secure networks. Right?
I tested on Opera, Chrome, and Mozilla.

This is what the Mozilla console shows:
imagen_2021-12-03_112544

This is the Opera browser:
imagen_2021-12-03_112643

And finally chrome:
imagen_2021-12-03_112801

Thank you very much for your time.

@ccoreilly
Copy link
Owner

ccoreilly commented Dec 3, 2021

Oh, I see. You have to pass the sampleRate to the recognizer constructor model.KaldiRecognizer(16000)

I guess I need to update the docs or examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants