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 5, 2019
1 parent 124f767 commit a96e3d3
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion ESP32_SpeechRecognition.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Author: https://www.facebook.com/francefu 2019-08-05 05:30
Author: https://www.facebook.com/francefu 2019-08-05 19:00
Page
https://fustyles.github.io/webduino/ESP32_SpeechRecognition.html?STAIP&en-US
Expand Down Expand Up @@ -129,6 +129,9 @@
var one_line = /\n/g;
var first_char = /\S/;

var myString = "";
var myTimer;

if ('webkitSpeechRecognition' in window) {
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
Expand Down Expand Up @@ -201,6 +204,24 @@
Recognition_final = "";
document.getElementById("showText").innerHTML = Recognition_interim;
console.log(Recognition_interim);

clearTimeout(myTimer);
myString = Recognition_interim;
myTimer = setTimeout(function() {
if (myString==document.getElementById("showText").innerHTML&&myString!="") {
if (myString.toLowerCase().trim()=="ok"||myString.toLowerCase().trim()=="okay") {
document.getElementById("showText").innerHTML = "";
document.getElementById("result").innerHTML = "";
location.href = document.getElementById("command").innerHTML;
return;
}
else {
document.getElementById("showText").innerHTML = "";
document.getElementById("result").innerHTML = myString;
document.getElementById("command").innerHTML = "http://" +STAIP + "?speech=" + myString.toLowerCase().trim() + ";" + document.getElementById("lang").value;
}
}
}, 3000);
}
if (document.getElementById("showText").innerHTML!="") {
document.getElementById("result").innerHTML = "";
Expand Down

0 comments on commit a96e3d3

Please sign in to comment.