Skip to content

Commit 7d65dd4

Browse files
authored
Bring ML APIs up to standard. (#346)
1 parent 1984122 commit 7d65dd4

File tree

5 files changed

+123
-86
lines changed

5 files changed

+123
-86
lines changed

speech/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
},
1010
"dependencies": {
1111
"@google-cloud/speech": "0.9.0",
12-
"@google-cloud/storage": "0.7.0",
13-
"node-record-lpcm16": "0.2.0",
14-
"yargs": "6.6.0"
12+
"@google-cloud/storage": "1.0.0",
13+
"node-record-lpcm16": "0.3.0",
14+
"yargs": "7.0.2"
1515
},
1616
"engines": {
1717
"node": ">=4.3.2"

speech/quickstart.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,8 @@ speechClient.recognize(fileName, options)
4242
.then((results) => {
4343
const transcription = results[0];
4444
console.log(`Transcription: ${transcription}`);
45+
})
46+
.catch((err) => {
47+
console.error('ERROR:', err);
4548
});
4649
// [END speech_quickstart]

speech/recognize.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ function syncRecognize (filename, encoding, sampleRateHertz, languageCode) {
5555
const transcription = results[0];
5656

5757
console.log(`Transcription: ${transcription}`);
58+
})
59+
.catch((err) => {
60+
console.error('ERROR:', err);
5861
});
5962
// [END speech_sync_recognize]
6063
}
@@ -91,6 +94,9 @@ function syncRecognizeGCS (gcsUri, encoding, sampleRateHertz, languageCode) {
9194
const transcription = results[0];
9295

9396
console.log(`Transcription: ${transcription}`);
97+
})
98+
.catch((err) => {
99+
console.error('ERROR:', err);
94100
});
95101
// [END speech_sync_recognize_gcs]
96102
}
@@ -131,6 +137,9 @@ function asyncRecognize (filename, encoding, sampleRateHertz, languageCode) {
131137
})
132138
.then((transcription) => {
133139
console.log(`Transcription: ${transcription}`);
140+
})
141+
.catch((err) => {
142+
console.error('ERROR:', err);
134143
});
135144
// [END speech_async_recognize]
136145
}
@@ -171,6 +180,9 @@ function asyncRecognizeGCS (gcsUri, encoding, sampleRateHertz, languageCode) {
171180
})
172181
.then((transcription) => {
173182
console.log(`Transcription: ${transcription}`);
183+
})
184+
.catch((err) => {
185+
console.error('ERROR:', err);
174186
});
175187
// [END speech_async_recognize_gcs]
176188
}
@@ -209,7 +221,7 @@ function streamingRecognize (filename, encoding, sampleRateHertz, languageCode)
209221
const recognizeStream = speech.createRecognizeStream(request)
210222
.on('error', console.error)
211223
.on('data', (data) => {
212-
console.log('Data received: %j', data);
224+
console.log(`Transcription: ${data.results}`);
213225
});
214226

215227
// Stream an audio file from disk to the Speech API, e.g. "./resources/audio.raw"

speech/system-test/recognize.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ test(`should run async recognize on a GCS file`, async (t) => {
6262

6363
test(`should run streaming recognize`, async (t) => {
6464
const output = await runAsync(`${cmd} stream ${filepath}`, cwd);
65-
t.true(output.includes(text));
65+
t.true(output.includes(`Transcription: ${text}`));
6666
});

0 commit comments

Comments
 (0)