Skip to content

Commit

Permalink
Update ESP32_SpeechRecognition.html
Browse files Browse the repository at this point in the history
  • Loading branch information
fustyles authored Aug 4, 2019
1 parent bfe0909 commit 4d89bd9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ESP32_SpeechRecognition.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,12 @@
<div id="command" style="color:blue;font-weight:bold;"></div>

<script>
var final_transcript = '';
var recognizing = false;
var ignore_onend;
var two_line = /\n\n/g;
var one_line = /\n/g;
var first_char = /\S/;
var Recognition_interim = '';
var Recognition_final = '';

if ('webkitSpeechRecognition' in window) {
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
Expand Down Expand Up @@ -160,12 +158,14 @@
recognition.onend = function() {
recognizing = false;
if (ignore_onend) return;
if (!final_transcript) return;
recognition.start();
};

recognition.onresult = function(event) {
var interim_transcript = '';
var final_transcript = '';
var Recognition_interim = '';
var Recognition_final = '';
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
final_transcript = event.results[i][0].transcript;
Expand Down Expand Up @@ -210,7 +210,6 @@
if (recognizing) {
recognition.stop();
}
final_transcript = '';
recognition.start();
ignore_onend = false;
}
Expand Down

0 comments on commit 4d89bd9

Please sign in to comment.