diff options
author | matthewsotoudeh <matthewsot@outlook.com> | 2017-02-05 12:47:57 -0800 |
---|---|---|
committer | matthewsotoudeh <matthewsot@outlook.com> | 2017-02-05 12:47:57 -0800 |
commit | df15aa053e5bf3e4f67c7612cf475e0ddcf854d7 (patch) | |
tree | 702f42960d6b6b4395a79db5ca37d49e31412a8b | |
parent | bb55c3a292dca512605ebeb83faec6ad15304c1f (diff) |
abort instead of stop
-rw-r--r-- | content/scripts/speech-rec.js | 6 | ||||
-rw-r--r-- | ps/sr-abstraction.js | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/content/scripts/speech-rec.js b/content/scripts/speech-rec.js index b8faa91..23e6a53 100644 --- a/content/scripts/speech-rec.js +++ b/content/scripts/speech-rec.js @@ -14,6 +14,8 @@ speechRecognizer.finalHypothesisCallback = function (hyp) { //Prime the speech recognition with ~0.5s of previous data setInterval(function () { if (window.recognizingSpeech) return; - speechRecognizer.stopRecognizing(); - speechRecognizer.startRecognizing(); + try { + speechRecognizer.stopRecognizing(true); + speechRecognizer.startRecognizing(); + } catch (err) { } }, 500); diff --git a/ps/sr-abstraction.js b/ps/sr-abstraction.js index 3cb4fc3..215be09 100644 --- a/ps/sr-abstraction.js +++ b/ps/sr-abstraction.js @@ -42,7 +42,11 @@ if (typeof SpeechRecognition == "undefined" && typeof webkitSpeechRecognition == speechRecognizer.startRecognizing = function () { recognition.start(); }; - speechRecognizer.stopRecognizing = function () { - recognition.stop(); + speechRecognizer.stopRecognizing = function (abort) { + if (abort) { + recognition.abort(); + } else { + recognition.stop(); + } }; } |