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

demo/nodejs/test_microphone doesn't work on Windows due to an issue in mic package #1203

Open
lexasss opened this issue Nov 18, 2022 · 3 comments · May be fixed by #1303
Open

demo/nodejs/test_microphone doesn't work on Windows due to an issue in mic package #1203

lexasss opened this issue Nov 18, 2022 · 3 comments · May be fixed by #1303

Comments

@lexasss
Copy link

lexasss commented Nov 18, 2022

The test_microphone.js example does not work due to an issue in mic@2.1.1 package it uses. This package is a JS binding for SoX audio tool. On Windows, it calls sox.exe with the parameter -p that is a shortcut for -t sox -, i.e. sets the data format equal to sox. The sox format is always 32-bit, while vosk.Recognizer expects 16-bit data captured from a microphone. Configuring the data value size with -b parameter set to 16 (bitwidth: '16' when creating mic instance in the test_microphone.js) does not help, it is simply ignored.

The issue can be solved by modifying mic.js file from the mic package on line 50 and replacing '-p' with '-t', 'raw', '-'. A solution could be forking this package (as the author does not maintain it anymore) and correcting the set of parameters passed to sox.exe. Similar package, node-microphone, is providing same -p parameter when launching sox.exe on Windows, thus same issue could be expected.

@nshmyrev
Copy link
Collaborator

Yes, we need to move to node-portaudio or some other more reasonable package.

@sebastientromp
Copy link

Thanks, that helped me get unstuck :)

@BrunoHenrique00
Copy link

Yeap, this solved the issue for me as well :). For sure need to change Microphone example in Node.js.
I created a simple example without any external lib to deal with a microphone but using Sox anyway.

Will send a PR to change the example above!

BrunoHenrique00 added a commit to BrunoHenrique00/vosk-api that referenced this issue Mar 23, 2023
@BrunoHenrique00 BrunoHenrique00 linked a pull request Mar 23, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

4 participants