Skip to content

Commit

Permalink
Enforce SpeechRecognition.maxAlternatives
Browse files Browse the repository at this point in the history
  • Loading branch information
abrichr committed Oct 6, 2015
1 parent b6f62d1 commit 81ad9a5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion annyang.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@
// Map the results to an array
var SpeechRecognitionResult = event.results[event.resultIndex];
var results = [];
for (var k = 0; k<SpeechRecognitionResult.length; k++) {
// Enforce maxAlternatives (not respected by Chrome on Android)
var K = Math.min(SpeechRecognitionResult.length, recognition.maxAlternatives);
for (var k = 0; k < K; k++) {
results[k] = SpeechRecognitionResult[k].transcript;
}

Expand Down

0 comments on commit 81ad9a5

Please sign in to comment.