Skip to content

Commit

Permalink
docs: update to sample in READMEs (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation committed Oct 22, 2020
1 parent add8d2d commit 980ba6e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
20 changes: 10 additions & 10 deletions packages/google-cloud-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -93,7 +93,7 @@ async function main() {
.join('\n');
console.log(`Transcription: ${transcription}`);
}
main().catch(console.error);
quickstart();

```

Expand All @@ -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) |


Expand Down
20 changes: 13 additions & 7 deletions packages/google-cloud-node/samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).

Expand All @@ -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 <encoding> <sampleRateHertz> <languageCode>`


-----
Expand All @@ -71,14 +73,16 @@ __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)

__Usage:__


`node samples/infiniteStreaming.js`
`node infiniteStreaming.js <encoding> <sampleRateHertz> <languageCode> <streamingLimit>`


-----
Expand Down Expand Up @@ -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).

Expand All @@ -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 <encoding> <sampleRateHertz> <languageCode>`


-----
Expand Down
2 changes: 1 addition & 1 deletion packages/google-cloud-node/synth.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"git": {
"name": ".",
"remote": "https://github.com/googleapis/nodejs-speech.git",
"sha": "9262e68c0dabf0fffd4771c3b210db0b08d4aa49"
"sha": "19650162128148f62ffe82e88175e82808fc9ac2"
}
},
{
Expand Down

0 comments on commit 980ba6e

Please sign in to comment.