-
Notifications
You must be signed in to change notification settings - Fork 291
Unable to capture audio from microphone on Cloud Speech API #13
Comments
I have almost same problem on Windows 10, works fine on macOS. |
The 'rec' option was removed from sox at windows, so you need to fix the file directly from node_modules. I found the solution here: gillesdemey/node-record-lpcm16#8 |
@abepadilla @kadoyau could you try this out and report back? |
I'm having the same issue as @abepadilla and @kadoyau only helps with the "Error: spawn rec ENOENT" error. Once I did that, I stopped getting the aforementioned error. Now I'm exactly at the situation @abepadilla describes. The script stops immediately without any error or transcript returned. |
Hi All @abepadilla @atifsajjad , I have managed to make the code work on Windows. It is mainly the problem of the node-record-lpcm16 problem. Here are my two cents:
'use strict' var spawn = require('child_process').spawn var cp // Recording process // returns a Readable stream var defaults = { options = Object.assign(defaults, options) var cmd = 'sox'; // Capture audio stream
}*/ // Spawn audio capture command if (options.verbose) {
} return rec exports.stop = function () { cp.kill() // Exit the spawned process, exit gracefully
'use strict' var record = require('../') //Node: please replace this with the correct path to your node-record-lpcm16 module. var file = fs.createWriteStream('test.raw', { encoding: 'binary' }) record.start().pipe(file) // Stop recording after three seconds and write to file
const record = require('path to your node-record-lpcm16-master module'); // Imports the Google Cloud client library // Creates a client /**
const request = { // Create a recognize stream // Start recording and send the microphone input to the Speech API // Stop recording after three seconds console.log('Listening, press Ctrl+C to stop.');
Hope this helps! |
@ycai003 that was incredibly helpful, thank you! |
Once
node recognize.js listen
is executed, it stops immediately but no error message is displayed. The input should be coming from a microphone. And the main purpose is to transcribe the audio from the microphone using Node.js.A. Details
B. Steps to reproduce
recognize.js
was there.
sudo apt-get install sox libsox-fmt-all
.export GOOGLE_APPLICATION_CREDENTIALS="path/to/service_account.json”
recordProgram
parameter value tosox
if it doesn’t work change itrec
orarecord
.node recognize.js listen
Listening, press Ctrl+C to stop.
Thank you so much!
The text was updated successfully, but these errors were encountered: