Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Add streaming microphone sample for Speech #87

Merged
merged 10 commits into from
Sep 10, 2018

Conversation

CallistoCF
Copy link
Contributor

For @Beccca preliminary review

Command line microphone streaming example in node, run MicrophoneStream.js --help

@googlebot
Copy link

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. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label Jun 8, 2018
@codecov
Copy link

codecov bot commented Jun 8, 2018

Codecov Report

Merging #87 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #87   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines          34     34           
=====================================
  Hits           34     34

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2c42b5...97aec14. Read the comment docs.

@beccasaurus beccasaurus self-assigned this Jun 11, 2018
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.

.map(result => result.alternatives[0].confidence)
.join('\n');
console.log(`wavFileToText: Confidence; \n`, confidence);
// ResultsArray.push([transcription, confidence]);

This comment was marked as spam.


const {runAsync} = require(`@google-cloud/nodejs-repo-tools`);

//const bucketName = `nodejs-docs-samples-test-${uuid.v4()}`;

This comment was marked as spam.

'use strict';

const path = require(`path`);
//const storage = require(`@google-cloud/storage`)();

This comment was marked as spam.

@@ -0,0 +1,45 @@
/**
* Copyright 2016, Google, Inc.

This comment was marked as spam.

@@ -0,0 +1,332 @@
/**

This comment was marked as spam.

This comment was marked as spam.

@ghost ghost assigned JustinBeckwith Jun 13, 2018
@JustinBeckwith JustinBeckwith removed their assignment Jun 13, 2018
.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.

@beccasaurus
Copy link
Contributor

Where are the tests?

setTimeout(function() {
record.stop();
console.log(`micStreamRecognize: Recording complete!`);
console.log(

This comment was marked as spam.

// [END micStreamRecognize]
}

function wavFileToText(filename, encoding, sampleRateHertz, languageCode) {

This comment was marked as spam.

// [END wavFileToText]
}

function test_1(

This comment was marked as spam.

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.

// Creates a client
const client = new speech.SpeechClient();

//Creates an array of interim results, for testing

This comment was marked as spam.


//Node-Record-lpcm16
const record = require('node-record-lpcm16');
//https://www.npmjs.com/package/node-record-lpcm16

This comment was marked as spam.

interimResults: true, // If you want interim results, set this to true
};

//To write .wav to file

This comment was marked as spam.


const request = {
config,
interimResults: true, // If you want interim results, set this to true

This comment was marked as spam.

languageCode
) {
// [START micStreamRecognize]
//returns speech-to-text, from streamingRecognize - request object is simplified

This comment was marked as spam.

// [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.

) {
// [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.

* 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.

@beccasaurus beccasaurus removed their assignment Aug 3, 2018
Copy link
Contributor

@happyhuman happyhuman left a 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.

@@ -0,0 +1,30 @@
/**
* Copyright 2016, Google, Inc.

This comment was marked as spam.

@JustinBeckwith
Copy link
Contributor

@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?

@ghost ghost assigned beccasaurus Sep 10, 2018
@JustinBeckwith JustinBeckwith added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Sep 10, 2018
@googlebot
Copy link

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.)

@JustinBeckwith JustinBeckwith changed the title [DO NOT MERGE] Add streaming microphone sample for Speech Add streaming microphone sample for Speech Sep 10, 2018
@JustinBeckwith JustinBeckwith merged commit 5760658 into googleapis:master Sep 10, 2018
@@ -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.

This comment was marked as spam.

@JustinBeckwith JustinBeckwith mentioned this pull request Sep 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants