-
Notifications
You must be signed in to change notification settings - Fork 289
Add streaming microphone sample for Speech #87
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
Codecov Report
@@ Coverage Diff @@
## master #87 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 2 2
Lines 34 34
=====================================
Hits 34 34 Continue to review full report at Codecov.
|
const cwd = path.join(__dirname, `..`); | ||
const filename = `ManualTest.wav`; | ||
const filepath = path.join(__dirname, `../resources/${filename}`); | ||
const text = `neewer manual test 10:39 Friday`; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicrophoneStream.js
Outdated
.map(result => result.alternatives[0].confidence) | ||
.join('\n'); | ||
console.log(`wavFileToText: Confidence; \n`, confidence); | ||
// ResultsArray.push([transcription, confidence]); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
||
const {runAsync} = require(`@google-cloud/nodejs-repo-tools`); | ||
|
||
//const bucketName = `nodejs-docs-samples-test-${uuid.v4()}`; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
'use strict'; | ||
|
||
const path = require(`path`); | ||
//const storage = require(`@google-cloud/storage`)(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -0,0 +1,45 @@ | |||
/** | |||
* Copyright 2016, Google, Inc. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
@@ -0,0 +1,332 @@ | |||
/** |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
.demand(1) | ||
.command( | ||
`run`, | ||
`Runs complete streaming test: \n 1. streams from microphone, outputting streamed speech-to-text to console, \n 2. records that streamed sample to resources folder, \n 3. runs speech-to-text on that local file to compare to step 1.`, |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Where are the tests? |
samples/MicStream.js
Outdated
setTimeout(function() { | ||
record.stop(); | ||
console.log(`micStreamRecognize: Recording complete!`); | ||
console.log( |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
// [END micStreamRecognize] | ||
} | ||
|
||
function wavFileToText(filename, encoding, sampleRateHertz, languageCode) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
// [END wavFileToText] | ||
} | ||
|
||
function test_1( |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
var InterimResults = []; | ||
|
||
//defensive code in case user doesn't specify audio file type | ||
if (filename.substr(filename.length - 4) !== `.wav`) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
// Creates a client | ||
const client = new speech.SpeechClient(); | ||
|
||
//Creates an array of interim results, for testing |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
|
||
//Node-Record-lpcm16 | ||
const record = require('node-record-lpcm16'); | ||
//https://www.npmjs.com/package/node-record-lpcm16 |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
interimResults: true, // If you want interim results, set this to true | ||
}; | ||
|
||
//To write .wav to file |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
|
||
const request = { | ||
config, | ||
interimResults: true, // If you want interim results, set this to true |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
languageCode | ||
) { | ||
// [START micStreamRecognize] | ||
//returns speech-to-text, from streamingRecognize - request object is simplified |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
// [START micStreamRecognize] | ||
//returns speech-to-text, from streamingRecognize - request object is simplified | ||
//streams audio from microphone to filename, for secondsofRecording seconds, using simplified request object | ||
//config is .wav by default, change request object (see above) for more options. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
) { | ||
// [START micStreamRecognize] | ||
//returns speech-to-text, from streamingRecognize - request object is simplified | ||
//streams audio from microphone to filename, for secondsofRecording seconds, using simplified request object |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
samples/MicStream.js
Outdated
* More Info: https://cloud.google.com/speech-to-text/docs/streaming-recognize | ||
*/ | ||
|
||
//uncomment below and see Errata at end of file for more configurations |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after fixing my two minor comments.
@@ -0,0 +1,129 @@ | |||
/** | |||
* Copyright 2017, Google, Inc. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -0,0 +1,30 @@ | |||
/** | |||
* Copyright 2016, Google, Inc. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@Beccca @happyhuman 👋 What's the status of this PR? It's been hanging around for a while :) Anything we can do to help get it merged? |
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) |
@@ -2,149 +2,140 @@ | |||
[//]: # "To regenerate it, use `npm run generate-scaffolding`." | |||
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/> | |||
|
|||
# [Google Cloud Speech API: Node.js Client](https://github.com/googleapis/nodejs-speech) | |||
# Google Cloud Speech API: Node.js Samples |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
For @Beccca preliminary review
Command line microphone streaming example in node, run MicrophoneStream.js --help