Skip to content

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

@jmp1548

Description

@jmp1548

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🚨This issue needs some love.triage meI really want to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions