Skip to content

Commit 980ba6e

Browse files
docs: update to sample in READMEs (#662)
1 parent add8d2d commit 980ba6e

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

packages/google-cloud-node/README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,19 @@ npm install @google-cloud/speech
5757
### Using the client library
5858

5959
```javascript
60-
async function main() {
61-
// Imports the Google Cloud client library
62-
const speech = require('@google-cloud/speech');
63-
const fs = require('fs');
60+
// Imports the Google Cloud client library
61+
const speech = require('@google-cloud/speech');
62+
const fs = require('fs').promises;
6463

65-
// Creates a client
66-
const client = new speech.SpeechClient();
64+
// Creates a client
65+
const client = new speech.SpeechClient();
6766

67+
async function quickstart() {
6868
// The name of the audio file to transcribe
6969
const fileName = './resources/audio.raw';
7070

7171
// Reads a local audio file and converts it to base64
72-
const file = fs.readFileSync(fileName);
72+
const file = await fs.readFile(fileName);
7373
const audioBytes = file.toString('base64');
7474

7575
// The audio file's encoding, sample rate in hertz, and BCP-47 language code
@@ -93,7 +93,7 @@ async function main() {
9393
.join('\n');
9494
console.log(`Transcription: ${transcription}`);
9595
}
96-
main().catch(console.error);
96+
quickstart();
9797

9898
```
9999

@@ -106,12 +106,12 @@ has instructions for running the samples.
106106

107107
| Sample | Source Code | Try it |
108108
| --------------------------- | --------------------------------- | ------ |
109-
| 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) |
109+
| 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) |
110110
| 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) |
111111
| 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) |
112112
| 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) |
113113
| 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) |
114-
| 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) |
114+
| 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) |
115115
| 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) |
116116

117117

packages/google-cloud-node/samples/README.md

+13-7
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
* [Before you begin](#before-you-begin)
1414
* [Samples](#samples)
15-
* [Microphone Stream](#microphone-stream)
15+
* [Microphone stream](#microphone-stream)
1616
* [Beta Features](#beta-features)
1717
* [Infinite Streaming](#infinite-streaming)
1818
* [Quickstart](#quickstart)
1919
* [Recognize](#recognize)
20-
* [Recognize.v1p1beta1](#recognize.v1p1beta1)
20+
* [Recognize speech with metadata](#recognize-speech-with-metadata)
2121
* [Transcribe Context Classes](#transcribe-context-classes)
2222

2323
## Before you begin
@@ -35,7 +35,9 @@ Before running the samples, make sure you've followed the steps outlined in
3535

3636

3737

38-
### Microphone Stream
38+
### Microphone stream
39+
40+
Streams audio input from microphone, translates to text.
3941

4042
View the [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/MicrophoneStream.js).
4143

@@ -44,7 +46,7 @@ View the [source code](https://github.com/googleapis/nodejs-speech/blob/master/s
4446
__Usage:__
4547

4648

47-
`node samples/MicrophoneStream.js`
49+
`node MicrophoneStream.js <encoding> <sampleRateHertz> <languageCode>`
4850

4951

5052
-----
@@ -71,14 +73,16 @@ __Usage:__
7173

7274
### Infinite Streaming
7375

76+
Performs infinite streaming using the streamingRecognize operation with the Cloud Speech API.
77+
7478
View the [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/infiniteStreaming.js).
7579

7680
[![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)
7781

7882
__Usage:__
7983

8084

81-
`node samples/infiniteStreaming.js`
85+
`node infiniteStreaming.js <encoding> <sampleRateHertz> <languageCode> <streamingLimit>`
8286

8387

8488
-----
@@ -120,7 +124,9 @@ __Usage:__
120124

121125

122126

123-
### Recognize.v1p1beta1
127+
### Recognize speech with metadata
128+
129+
Analyzes an audio stream, and detects speech along with metadata.
124130

125131
View the [source code](https://github.com/googleapis/nodejs-speech/blob/master/samples/recognize.v1p1beta1.js).
126132

@@ -129,7 +135,7 @@ View the [source code](https://github.com/googleapis/nodejs-speech/blob/master/s
129135
__Usage:__
130136

131137

132-
`node samples/recognize.v1p1beta1.js`
138+
`node recognize.v1p1beta1.js ./resources/commercial_mono.wav <encoding> <sampleRateHertz> <languageCode>`
133139

134140

135141
-----

packages/google-cloud-node/synth.metadata

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"git": {
55
"name": ".",
66
"remote": "https://github.com/googleapis/nodejs-speech.git",
7-
"sha": "9262e68c0dabf0fffd4771c3b210db0b08d4aa49"
7+
"sha": "19650162128148f62ffe82e88175e82808fc9ac2"
88
}
99
},
1010
{

0 commit comments

Comments
 (0)