alphacep / alphacep/vosk-api

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

Open
#1,203 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
15.1k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

The [test_microphone.js](https://github.com/alphacep/vosk-api/blob/master/nodejs/demo/test_microphone.js) example does not work due to an issue in [mic@2.1.1](https://github.com/ashishbajaj99/mic) 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](https://github.com/ashishbajaj99/mic/blob/master/lib/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](https://www.npmjs.com/package/node-microphone/v/0.1.4), is providing same `-p` parameter when launching `sox.exe` on Windows, thus same issue could be expected.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.