Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[speech-to-text] Add recognize options #199

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions services/speech_to_text/v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,7 @@ function RecognizeStream(options){

var queryParams = extend({model: 'en-US_BroadbandModel'}, pick(options, ['model', 'X-Watson-Learning-Opt-Out', 'watson-token']));

var openingMessage = extend({
// todo: confirm the mixed underscores/hyphens and/or get it fixed
action: 'start',
'content-type': 'audio/wav', // todo: try to determine content-type from the file extension if available
'continuous': false,
'interim_results': true
}, pick(options, [PARAMS_ALLOWED]));
var openingMessage = pick(options, PARAMS_ALLOWED);

var closingMessage = {action: 'stop'};

Expand Down Expand Up @@ -471,8 +465,8 @@ function RecognizeStream(options){
}
} else if (data.results) {
self.emit('results', data);
// note: currently there is always exactly 1 entry in the results array. However, this may change in the future.
if(data.results[0].final && data.results[0].alternatives) {
// note: usually exactly 1 entry in results. Edge case: zero entries. E.g., silent audio sent from pipeline
if(data.results[0] && data.results[0].final && data.results[0].alternatives) {
self.push(data.results[0].alternatives[0].transcript, 'utf8'); // this is the "data" event that can be easily piped to other streams
}
} else {
Expand Down
Binary file added test/resources/malformed.flac
Binary file not shown.
Binary file added test/resources/noise-1min.flac
Binary file not shown.
Binary file added test/resources/silence-1min.flac
Binary file not shown.