Skip to content

Commit

Permalink
Bring ML APIs up to standard. (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry authored and Ace Nassri committed Nov 17, 2022
1 parent e1ebe38 commit 6dc88cd
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 86 deletions.
6 changes: 3 additions & 3 deletions speech/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
},
"dependencies": {
"@google-cloud/speech": "0.9.0",
"@google-cloud/storage": "0.7.0",
"node-record-lpcm16": "0.2.0",
"yargs": "6.6.0"
"@google-cloud/storage": "1.0.0",
"node-record-lpcm16": "0.3.0",
"yargs": "7.0.2"
},
"engines": {
"node": ">=4.3.2"
Expand Down
3 changes: 3 additions & 0 deletions speech/quickstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ speechClient.recognize(fileName, options)
.then((results) => {
const transcription = results[0];
console.log(`Transcription: ${transcription}`);
})
.catch((err) => {
console.error('ERROR:', err);
});
// [END speech_quickstart]
14 changes: 13 additions & 1 deletion speech/recognize.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ function syncRecognize (filename, encoding, sampleRateHertz, languageCode) {
const transcription = results[0];

console.log(`Transcription: ${transcription}`);
})
.catch((err) => {
console.error('ERROR:', err);
});
// [END speech_sync_recognize]
}
Expand Down Expand Up @@ -91,6 +94,9 @@ function syncRecognizeGCS (gcsUri, encoding, sampleRateHertz, languageCode) {
const transcription = results[0];

console.log(`Transcription: ${transcription}`);
})
.catch((err) => {
console.error('ERROR:', err);
});
// [END speech_sync_recognize_gcs]
}
Expand Down Expand Up @@ -131,6 +137,9 @@ function asyncRecognize (filename, encoding, sampleRateHertz, languageCode) {
})
.then((transcription) => {
console.log(`Transcription: ${transcription}`);
})
.catch((err) => {
console.error('ERROR:', err);
});
// [END speech_async_recognize]
}
Expand Down Expand Up @@ -171,6 +180,9 @@ function asyncRecognizeGCS (gcsUri, encoding, sampleRateHertz, languageCode) {
})
.then((transcription) => {
console.log(`Transcription: ${transcription}`);
})
.catch((err) => {
console.error('ERROR:', err);
});
// [END speech_async_recognize_gcs]
}
Expand Down Expand Up @@ -209,7 +221,7 @@ function streamingRecognize (filename, encoding, sampleRateHertz, languageCode)
const recognizeStream = speech.createRecognizeStream(request)
.on('error', console.error)
.on('data', (data) => {
console.log('Data received: %j', data);
console.log(`Transcription: ${data.results}`);
});

// Stream an audio file from disk to the Speech API, e.g. "./resources/audio.raw"
Expand Down
2 changes: 1 addition & 1 deletion speech/system-test/recognize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ test(`should run async recognize on a GCS file`, async (t) => {

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

0 comments on commit 6dc88cd

Please sign in to comment.