From 980ba6e397fc2a25a96c354b7aa9959ae504bea7 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 22 Oct 2020 09:58:49 -0700 Subject: [PATCH] docs: update to sample in READMEs (#662) --- packages/google-cloud-node/README.md | 20 ++++++++++---------- packages/google-cloud-node/samples/README.md | 20 +++++++++++++------- packages/google-cloud-node/synth.metadata | 2 +- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/packages/google-cloud-node/README.md b/packages/google-cloud-node/README.md index 48248908eda2..b30e2af06e6b 100644 --- a/packages/google-cloud-node/README.md +++ b/packages/google-cloud-node/README.md @@ -57,19 +57,19 @@ npm install @google-cloud/speech ### Using the client library ```javascript -async function main() { - // Imports the Google Cloud client library - const speech = require('@google-cloud/speech'); - const fs = require('fs'); +// Imports the Google Cloud client library +const speech = require('@google-cloud/speech'); +const fs = require('fs').promises; - // Creates a client - const client = new speech.SpeechClient(); +// Creates a client +const client = new speech.SpeechClient(); +async function quickstart() { // The name of the audio file to transcribe const fileName = './resources/audio.raw'; // Reads a local audio file and converts it to base64 - const file = fs.readFileSync(fileName); + const file = await fs.readFile(fileName); const audioBytes = file.toString('base64'); // The audio file's encoding, sample rate in hertz, and BCP-47 language code @@ -93,7 +93,7 @@ async function main() { .join('\n'); console.log(`Transcription: ${transcription}`); } -main().catch(console.error); +quickstart(); ``` @@ -106,12 +106,12 @@ has instructions for running the samples. | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | -| Microphone Stream | [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/MicrophoneStream.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-speech&page=editor&open_in_editor=samples/MicrophoneStream.js,samples/README.md) | +| Microphone stream | [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/MicrophoneStream.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-speech&page=editor&open_in_editor=samples/MicrophoneStream.js,samples/README.md) | | Beta Features | [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/betaFeatures.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-speech&page=editor&open_in_editor=samples/betaFeatures.js,samples/README.md) | | Infinite Streaming | [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/infiniteStreaming.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-speech&page=editor&open_in_editor=samples/infiniteStreaming.js,samples/README.md) | | Quickstart | [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-speech&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | | Recognize | [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/recognize.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-speech&page=editor&open_in_editor=samples/recognize.js,samples/README.md) | -| Recognize.v1p1beta1 | [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/recognize.v1p1beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-speech&page=editor&open_in_editor=samples/recognize.v1p1beta1.js,samples/README.md) | +| Recognize speech with metadata | [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/recognize.v1p1beta1.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-speech&page=editor&open_in_editor=samples/recognize.v1p1beta1.js,samples/README.md) | | Transcribe Context Classes | [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/transcribeContextClasses.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-speech&page=editor&open_in_editor=samples/transcribeContextClasses.js,samples/README.md) | diff --git a/packages/google-cloud-node/samples/README.md b/packages/google-cloud-node/samples/README.md index 6649e8de1b67..77fe8eda4a84 100644 --- a/packages/google-cloud-node/samples/README.md +++ b/packages/google-cloud-node/samples/README.md @@ -12,12 +12,12 @@ * [Before you begin](#before-you-begin) * [Samples](#samples) - * [Microphone Stream](#microphone-stream) + * [Microphone stream](#microphone-stream) * [Beta Features](#beta-features) * [Infinite Streaming](#infinite-streaming) * [Quickstart](#quickstart) * [Recognize](#recognize) - * [Recognize.v1p1beta1](#recognize.v1p1beta1) + * [Recognize speech with metadata](#recognize-speech-with-metadata) * [Transcribe Context Classes](#transcribe-context-classes) ## Before you begin @@ -35,7 +35,9 @@ Before running the samples, make sure you've followed the steps outlined in -### Microphone Stream +### Microphone stream + +Streams audio input from microphone, translates to text. View the [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/MicrophoneStream.js). @@ -44,7 +46,7 @@ View the [source code](https://github.com/googleapis/nodejs-speech/blob/master/s __Usage:__ -`node samples/MicrophoneStream.js` +`node MicrophoneStream.js ` ----- @@ -71,6 +73,8 @@ __Usage:__ ### Infinite Streaming +Performs infinite streaming using the streamingRecognize operation with the Cloud Speech API. + View the [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/infiniteStreaming.js). [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-speech&page=editor&open_in_editor=samples/infiniteStreaming.js,samples/README.md) @@ -78,7 +82,7 @@ View the [source code](https://github.com/googleapis/nodejs-speech/blob/master/s __Usage:__ -`node samples/infiniteStreaming.js` +`node infiniteStreaming.js ` ----- @@ -120,7 +124,9 @@ __Usage:__ -### Recognize.v1p1beta1 +### Recognize speech with metadata + +Analyzes an audio stream, and detects speech along with metadata. View the [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/recognize.v1p1beta1.js). @@ -129,7 +135,7 @@ View the [source code](https://github.com/googleapis/nodejs-speech/blob/master/s __Usage:__ -`node samples/recognize.v1p1beta1.js` +`node recognize.v1p1beta1.js ./resources/commercial_mono.wav ` ----- diff --git a/packages/google-cloud-node/synth.metadata b/packages/google-cloud-node/synth.metadata index dd9d3bdf6b58..b24d031f899f 100644 --- a/packages/google-cloud-node/synth.metadata +++ b/packages/google-cloud-node/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-speech.git", - "sha": "9262e68c0dabf0fffd4771c3b210db0b08d4aa49" + "sha": "19650162128148f62ffe82e88175e82808fc9ac2" } }, {