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

Unable to record using node.js example #409

Closed
josefsandoval opened this issue Jun 26, 2017 · 7 comments
Closed

Unable to record using node.js example #409

josefsandoval opened this issue Jun 26, 2017 · 7 comments
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@josefsandoval
Copy link

Hello
I am trying to use the google cloud speech API. I already created a cloud project and got authenticated.
I also have created a service account key and got the json file that comes with it as well.

I am trying to get this example to work: Performing Streaming Speech Recognition on an Audio Stream
Link: https://cloud.google.com/speech/docs/streaming-recognize

Here is the code I am running on the command line with node

// [START speech_streaming_mic_recognize]
  const record = require('node-record-lpcm16');

    // Your Google Cloud Platform project ID
  const projectId = 'my projects name';

  const  keyFilename = 'path to my key .json file ';

  // Imports the Google Cloud client library
  const Speech = require('@google-cloud/speech');

  // Instantiates a client
  const speech = Speech({
      projectId: projectId,
      keyFilename: keyFilename
  });

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

  // Create a recognize stream
  const recognizeStream = speech.createRecognizeStream(request)
    .on('error', console.error)
    .on('data', (data) => process.stdout.write(data.results));

  // Start recording and send the microphone input to the Speech API
  record
    .start({
      sampleRateHertz: 16000,
      threshold: 0,
      // Other options, see https://www.npmjs.com/package/node-record-lpcm16#options
      verbose: false,
      recordProgram: 'sox', // 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]

whenever I try to run this program from command line using node, it just displays
"Listening, press Ctrl+C to stop." and then ends immediately, not allowing me to record and output my speech.

Does anyone know how to solve this issue?
Or am I doing something wrong?

Help would be greatly appreciated!!
Thanks!

@rjpruitt16
Copy link

Did you ever figure out the problem? I am having the same issue.

@shivag12
Copy link

In which environment you are trying to execute this. ??.. You need to have sox installed if its a windows machine.

@rjpruitt16
Copy link

I have been trying to execute the code in c9.io. It's an online Ubuntu environment. I also tried installing sox, but the result was the same.

@josefsandoval
Copy link
Author

Never got it solved. I tried on Ubuntu and windows. I had sox installed as well but it still didn't fix the problem

@shivag12
Copy link

I have the same problem with Windows , it did worked for me on raspberry pi, The actual issue is with the port in which Mic is connected and mine was connected to 0, So I have added an device option on record variable . "device : 'plughw:0'".

@jacob7182
Copy link

Is this device option for windows? I have been trying the recognize.js listen command but it is not recording or streaming to text. anyone able to run the listen method on Windows?

@fhinkel
Copy link
Contributor

fhinkel commented Nov 8, 2018

If the issue still persists, please file it here. Thank you.

@fhinkel fhinkel closed this as completed Nov 8, 2018
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 6, 2020
NimJay pushed a commit that referenced this issue Nov 11, 2022
🤖 I have created a release \*beep\* \*boop\* 
---
## [2.3.0](https://www.github.com/googleapis/nodejs-kms/compare/v2.2.0...v2.3.0) (2021-01-08)


### Features

* **samples:** add integrity verification to Cloud KMS crypto samples ([#409](https://www.github.com/googleapis/nodejs-kms/issues/409)) ([d2897f6](https://www.github.com/googleapis/nodejs-kms/commit/d2897f681ae409b34a50b91ea718fa9e294895c5))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please).
ace-n pushed a commit that referenced this issue Nov 11, 2022
🤖 I have created a release \*beep\* \*boop\* 
---
## [2.3.0](https://www.github.com/googleapis/nodejs-kms/compare/v2.2.0...v2.3.0) (2021-01-08)


### Features

* **samples:** add integrity verification to Cloud KMS crypto samples ([#409](https://www.github.com/googleapis/nodejs-kms/issues/409)) ([d2897f6](https://www.github.com/googleapis/nodejs-kms/commit/d2897f681ae409b34a50b91ea718fa9e294895c5))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please).
ace-n pushed a commit that referenced this issue Nov 17, 2022
ace-n pushed a commit that referenced this issue Nov 17, 2022
ace-n pushed a commit that referenced this issue Nov 17, 2022
ace-n pushed a commit that referenced this issue Nov 17, 2022
ace-n pushed a commit that referenced this issue Nov 17, 2022
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

7 participants