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

Google Speech recognize.js listen not recording on Raspberry pi #375

Closed
jmp1548 opened this issue May 4, 2017 · 2 comments
Closed

Google Speech recognize.js listen not recording on Raspberry pi #375

jmp1548 opened this issue May 4, 2017 · 2 comments
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@jmp1548
Copy link

jmp1548 commented May 4, 2017

Hi All,

I am trying the run the streamingMicRecognize function in recognize.js.
Whenever I run this on my raspberry pi (with a usb mic (that works with arecord)) the recording stream end immediately.

Here is my code (modified slightly)

const streamingMicRecognize = () => {
  console.log("Stream");
  // console.dir(recognizeStream);

  const recognizeStream = speech.createRecognizeStream(config).on('error', console.error).on('data', data => {
    console.log('recongizeStream > data');
    // record.stop();
    playback(data);
    process.stdout.write(data.results);
  }).on('end', () => {
    console.log("end stream")
  });
  // console.dir(recognizeStream);

  record.start({
    sampleRateHertz: 16000, threshold: 0,
    // Other options, see https://www.npmjs.com/package/node-record-lpcm16#options
    verbose: true,
    recordProgram: 'rec', // Try also "arecord" or "sox"
    silence: '10.0'
  }).on('error', console.error).pipe(recognizeStream);

  console.log('Listening, press Ctrl+C to stop.');
  // [END speech_streaming_mic_recognize]
}

When I run this with verbose mode set to true, I get this

Stream
Recording with sample rate 16000...
Listening, press Ctrl+C to stop.
Recording 5526 bytes
End Recording 91.384ms
end stream

The recording ends before I get a chance to speak. Not sure what could be causing that. If you need any more information, please let me know.

I should also note, that this works perfectly on my mac. Seems to be specific to the pi.

@jmp1548 jmp1548 closed this as completed May 4, 2017
@jmp1548
Copy link
Author

jmp1548 commented May 4, 2017

UPDATE: I had to manually set the device in the record settings. That fixed the issue for my pi. Now I have it working on both mac and pi.

  record.start({
    sampleRateHertz: 16000, threshold: 0,
    // Other options, see https://www.npmjs.com/package/node-record-lpcm16#options
    verbose: true,
    recordProgram: 'rec', // Try also "arecord" or "sox"
    silence: '10.0',
    device:  'plughw:0'
  }).on('error', console.error).pipe(recognizeStream);

@KaKi87
Copy link

KaKi87 commented Mar 16, 2018

Hi, how did you find out that the proper device is plughw:0 ?

Thanks

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 7, 2020
NimJay pushed a commit that referenced this issue Nov 9, 2022
1. Examine all the resources in the response.
2. I suspect, but cannot prove that the search function is eventually
   consistent.  So, give it some time.

Fixes googleapis/nodejs-talent#344
telpirion pushed a commit that referenced this issue Nov 9, 2022
1. Examine all the resources in the response.
2. I suspect, but cannot prove that the search function is eventually
   consistent.  So, give it some time.

Fixes googleapis/nodejs-talent#344
telpirion pushed a commit that referenced this issue Nov 9, 2022
1. Examine all the resources in the response.
2. I suspect, but cannot prove that the search function is eventually
   consistent.  So, give it some time.

Fixes googleapis/nodejs-talent#344
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants