1if ("webkitSpeechRecognition" in window) { 2 let speechRecognition = new webkitSpeechRecognition(); 3 let final_transcript = ""; 4 5 speechRecognition.continuous = true; 6 speechRecognition.interimResults = true; 7 speechRecognition.lang = 'en-US'; 8 9 speechRecognition.onstart = () => { 10 11 document.querySelector("#status_listening").style.display = "inline-block"; 12 document.querySelector("#stop_listening").style.display = "inline-block"; 13 }; 14 /* speechRecognition.onerror = () => { 15 document.querySelector("#status").style.display = "none"; 16 console.log("Speech Recognition Error"); 17 };*/ 18 19 speechRecognition.onerror = (event) => { 20 console.error(`Speech recognition error detected: ${event.error}`); 21 } 22 speechRecognition.onend = () => { 23 document.querySelector("#status_listening").style.display = "none"; 24 document.querySelector("#stop_listening").style.display = "none"; 25 console.log("Speech Recognition Ended"); 26 }; 27 28 speechRecognition.onresult = (event) => { 29 let interim_transcript = ""; 30 var final_transcript = ""; 31 // console.log(final_transcript); 32 33 for (let i = event.resultIndex; i < event.results.length; ++i) { 34 if (event.results[i].isFinal) { 35 final_transcript += event.results[i][0].transcript; 36 } else { 37 interim_transcript += event.results[i][0].transcript; 38 } 39 } 40 41 document.querySelector("#final_result").value = interim_transcript; 42 document.querySelector("#final_result").value = final_transcript; 43 44 }; 45 46 document.querySelector("#start_listening").onclick = () => { 47 speechRecognition.start(); 48 }; 49 document.querySelector("#stop_listening").onclick = () => { 50 speechRecognition.stop(); 51 document.querySelector("#stop_listening").style.display = "none"; 52 }; 53} else { 54 console.log("Speech Recognition Not Available"); 55}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.