Skip to content

Commit

Permalink
watson-developer-cloud#198 [speech-to-text] handle Edge case: zero re…
Browse files Browse the repository at this point in the history
…sult entries.
  • Loading branch information
monte-hayward committed Jan 8, 2016
1 parent 3db3b1d commit 8e73237
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions services/speech_to_text/v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,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

0 comments on commit 8e73237

Please sign in to comment.