nodejs-docs-samples icon indicating copy to clipboard operation
nodejs-docs-samples copied to clipboard

Unable to run recognize.JS

Open danishnazir opened this issue 9 years ago • 27 comments

Hi there ! Whenever i try to execute the recognize.JS file i get the following error command: node recognize listen Result:Listening, press Ctrl+C to stop. events.js:141 throw er; // Unhandled 'error' event ^ Error: spawn rec ENOENT at exports._errnoException (util.js:870:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32) at onErrorNT (internal/child_process.js:344:16) at nextTickCallbackWith2Args (node.js:442:9) at process._tickCallback (node.js:356:17) at Function.Module.runMain (module.js:443:11) at startup (node.js:139:18) at node.js:968:3

danishnazir avatar Apr 03 '17 16:04 danishnazir

I got around this by setting recordProgram to 'sox' in the options passed to record.start()

eg.

record.start({
    sampleRateHertz: sampleRateHertz,
    threshold: 0,
    recordProgram: 'sox'
  }).pipe(recognizeStream);

MarcPorciuncula avatar Apr 19 '17 13:04 MarcPorciuncula

@MarcoThePoro Now i get this error Error: spawn sox ENOENT at exports._errnoException (util.js:870:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32) at onErrorNT (internal/child_process.js:344:16) at nextTickCallbackWith2Args (node.js:442:9) at process._tickCallback (node.js:356:17) at Function.Module.runMain (module.js:443:11) at startup (node.js:139:18) at node.js:968:3

danishnazir avatar Apr 23 '17 13:04 danishnazir

Did you make sure to install SoX and add it to your path?

The speech example readme says this: Note: The listen command requires that you have SoX installed and available in your $PATH. See https://www.npmjs.com/package/node-record-lpcm16#dependencies.

On Sun., 23 Apr. 2017, 11:15 pm Danish Nazir, [email protected] wrote:

@MarcoThePoro https://github.com/MarcoThePoro Now i get this error Error: spawn sox ENOENT at exports._errnoException (util.js:870:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32) at onErrorNT (internal/child_process.js:344:16) at nextTickCallbackWith2Args (node.js:442:9) at process._tickCallback (node.js:356:17) at Function.Module.runMain (module.js:443:11) at startup (node.js:139:18) at node.js:968:3

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GoogleCloudPlatform/nodejs-docs-samples/issues/332#issuecomment-296442534, or mute the thread https://github.com/notifications/unsubscribe-auth/AHazr7u7m9mwAxMfZCG2yNVqU3d0R4_oks5ry07pgaJpZM4Mxyxp .

MarcPorciuncula avatar Apr 23 '17 14:04 MarcPorciuncula

Hi there yes i have installed it and now that problem is resolved thanks

danishnazir avatar Apr 23 '17 14:04 danishnazir

Hi @MarcoThePoro i have been able to successfully compile it but whenever i run it using the listen option it says Listening, press Ctrl+C to stop. but after this it automatically stop with no error messages! any ideas?

danishnazir avatar Apr 23 '17 17:04 danishnazir

I ran into that issue but just gave up then

On Mon., 24 Apr. 2017, 3:12 am Danish Nazir, [email protected] wrote:

Hi @MarcoThePoro https://github.com/MarcoThePoro i have been able to successfully compile it but whenever i run it using the listen option it says Listening, press Ctrl+C to stop. but after this it automatically stop with no error messages! any ideas?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GoogleCloudPlatform/nodejs-docs-samples/issues/332#issuecomment-296458093, or mute the thread https://github.com/notifications/unsubscribe-auth/AHazr044EM1K86cZNyqY48-lqQDVXp3iks5ry4aWgaJpZM4Mxyxp .

MarcPorciuncula avatar Apr 23 '17 22:04 MarcPorciuncula

@MarcoThePoro oh i see i am amazed to see that no one from google is helping us in solving this problem i mean where they? i am thoroughly disappointed!!

danishnazir avatar Apr 24 '17 08:04 danishnazir

@danishnazir Can you provide extensive details so we can reproduce the behavior you're experiencing? OS, Node version, @google-cloud/speech version, sox version, node-record-lpcm16 version, etc.

jmdobry avatar Apr 24 '17 19:04 jmdobry

Here are the details sox:v14.4.2 node:v4.4.4 @google-cloud/speech: same version as here in github repo as i am cloning node-record-lpcm16:same version as here in github repo as i am cloning @jmdobry

danishnazir avatar Apr 25 '17 06:04 danishnazir

We just updated this repo yesterday, so you might want to try re-cloning it and re-installing dependencies. You might also try upgrading Node.js to say, 6.10.1

jmdobry avatar Apr 25 '17 15:04 jmdobry

Hi @jmdobry i just reclonned the repo and upgraded my node setup but still same issue

danishnazir avatar Apr 25 '17 17:04 danishnazir

Can you try changing the options (found here) passed to record.start()? In particular, what happens if you change the silence option to "10.0", or what happens if you change the recordProgram option to "sox"?

jmdobry avatar Apr 25 '17 21:04 jmdobry

@jmdobry still the same problem!! Including the extra perimeters didn't help me!

  record.start({
    sampleRate: sampleRate,
    threshold: 0,
    recordProgram: 'sox',
    silence: 10.0  
  }).pipe(recognizeStream);

danishnazir avatar Apr 28 '17 18:04 danishnazir

I think the value for silence is supposed to be a string, and did you try different values for recordProgram and threshold?

jmdobry avatar Apr 28 '17 19:04 jmdobry

i tried using string too!! and no i havent manipulated the threshold yet

danishnazir avatar Apr 28 '17 19:04 danishnazir

Hello,

I am having the very same issue whenever I run using node . I just get "Listening, press Ctrl+C to stop" and the program stops running right away. I am using sox: v14.4.2 and nodejs : v6.11.0. Has anyone found a solution to this???

josefsandoval avatar Jun 26 '17 22:06 josefsandoval

@danishnazir Did you ever get it to work?

josefsandoval avatar Jun 30 '17 16:06 josefsandoval

No i left for ibm

On 30 Jun 2017 21:13, "josefsandoval" [email protected] wrote:

@danishnazir https://github.com/danishnazir Did you ever get it to work?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GoogleCloudPlatform/nodejs-docs-samples/issues/332#issuecomment-312309763, or mute the thread https://github.com/notifications/unsubscribe-auth/AH6LOiWAPw3OXOG6KAe3u6BmuwB4whz9ks5sJR6cgaJpZM4Mxyxp .

danishnazir avatar Jun 30 '17 16:06 danishnazir

@danishnazir I reached to the same point as you, getting no response, using the function : createRecognizeStream

const recognizeStream = speechClient.createRecognizeStream(request)

rather than streamingRecognize()

Now, using streamingRecognize(), I get the error :

Uncaught TypeError: speechClient.streamingRecognize is not a function

When i try accessing it through the api object of my speechClient instance, i get this error as response :

.google.cloud.speech.v1.StreamingRecognizeRequest#0 is not a field: undefined

Any help please ? @jmdobry ?

I would also like to know how to get the sample https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/speech/recognize.js run please....?

I am using : Win 10 Node js 7.10.0 sox 14.4.2

Thanks for any help on that issues !

Nathan4KImpact avatar Jul 23 '17 09:07 Nathan4KImpact

I can now run the sample https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/speech/recognize.js but getting no result, no error, as @danishnazir and others stated...

When I try to call the streamingRecognize() method in my own node.js app, the method be found

Uncaught TypeError: speechClient.streamingRecognize is not a function

This is my code :

`// The BCP-47 language code to use, e.g. 'en-US' const languageCode = settingsRecord.language; //'en-US';

        // Your Google Cloud Platform project ID
        const nathProjectId = 'protocol-recorder-201707';

        // Instantiates a client
        const speechClient = Speech({
            projectId: nathProjectId
            ,keyFilename: './rsc/credentials/spr-426ec2968cf6.json'
        });

        // The encoding of the audio file, e.g. 'LINEAR16'
        const encoding = 'LINEAR16';

        // The sample rate of the audio file in hertz, e.g. 16000
        const sampleRateHertz = 16000;          

        const request = {
            config: {
                encoding: encoding,
                sampleRateHertz: sampleRateHertz,
                languageCode: languageCode
                },  
            interimResults: false // If you want interim results, set this to true
        };

        // Create a recognize stream           
        var notes = '';  
        console.log('create the recognize Stream object to be piped..')
        //const recognizeStream = speechClient.createRecognizeStream(request)
        console.log("speechClient : ",speechClient)
        const recognizeStream = speechClient.api.Speech._streamingRecognize(request)
            .on('error', console.error)
            .on('data', (response) => {
                //process.stdout.write(response.results)   
                process.stdout.write(
                    (response.results[0] && response.results[0].alternatives[0])
                    ? `Transcription: ${response.results[0].alternatives[0].transcript}\n`
                    : `\n\nReached transcription time limit, press Ctrl+C\n`);                  
               
                notes = document.getElementById("notes").value;  
                notes = notes + response.results;
                document.getElementById("notes").value =  notes;
            });

        // Start recording and send the microphone input to the Speech API
        console.log('Start recording and send the microphone input to the Speech API..')
        record.start({
            sampleRateHertz: sampleRateHertz,
            threshold: 0,
            // Other options, see https://www.npmjs.com/package/node-record-lpcm16#options
            verbose: true,
            recordProgram: 'sox', // Try also "arecord" or "sox"
            silence: '1.0',
            device : settingsRecord.audio_input
        })
        .on('error', console.error)
        .pipe(recognizeStream);`

Could anyone clue me on what matters ?

Thanks

Nathan4KImpact avatar Jul 24 '17 13:07 Nathan4KImpact