diff --git a/annyang.js b/annyang.js index 7b60633..dcdde7b 100644 --- a/annyang.js +++ b/annyang.js @@ -42,6 +42,8 @@ var debugState = false; var debugStyle = 'font-weight: bold; color: #00f;'; var pauseListening = false; + var combinedTranscript = ''; + var combinedTranscriptTimeoutId; // The command matching code is a modified version of Backbone.Router by Jeremy Ashkenas, under the MIT license. var optionalParam = /\s*\((.*?)\)\s*/g; @@ -158,6 +160,14 @@ }; recognition.onend = function() { + if (combinedTranscriptTimeoutId) { + if (debugState) { + root.console.log('Ignoring combined transcript: %c', combinedTranscript, debugStyle); + } + clearTimeout(combinedTranscriptTimeoutId); + combinedTranscriptTimeoutId = null; + combinedTranscript = ''; + } invokeCallbacks(callbacks.end); // annyang will auto restart if it is closed automatically and not by user action. if (autoRestart) { @@ -182,7 +192,9 @@ // Map the results to an array var SpeechRecognitionResult = event.results[event.resultIndex]; var results = []; - for (var k = 0; k