From 691453559f4aaf6de97e4ce2ad233014267d503c Mon Sep 17 00:00:00 2001 From: fustyles <34397289+fustyles@users.noreply.github.com> Date: Mon, 9 Oct 2023 15:57:53 +0800 Subject: [PATCH] Update speechrecognition.js --- .../speechrecognition.js | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/SpeechRecognition_20220729/speechrecognition.js b/SpeechRecognition_20220729/speechrecognition.js index 3032c264b3..dc1ffcb795 100644 --- a/SpeechRecognition_20220729/speechrecognition.js +++ b/SpeechRecognition_20220729/speechrecognition.js @@ -46,15 +46,11 @@ if ('webkitSpeechRecognition' in window) { Recognition_final = linebreak(final_transcript); //console.log("final = " + Recognition_final); if (typeof SpeechRecognition_interim === 'object' && SpeechRecognition_interim !== null) { - if (SpeechRecognition_interim.textContent) - SpeechRecognition_interim.textContent = Recognition_final; - else if (SpeechRecognition_interim.innerText) - SpeechRecognition_interim.innerText = Recognition_final; - else if (SpeechRecognition_interim.innerHTML) - SpeechRecognition_interim.innerHTML = Recognition_final; + if (SpeechRecognition_interim.tagName.toLowerCase()=="input"||SpeechRecognition_interim.tagName.toLowerCase()=="textarea") + SpeechRecognition_interim.value = Recognition_final; else - SpeechRecognition_interim.value = Recognition_final; - } + SpeechRecognition_interim.innerHTML = Recognition_final; + } } else { Recognition_final = ""; @@ -71,16 +67,10 @@ if ('webkitSpeechRecognition' in window) { document.body.appendChild(obj); } document.getElementById("gamespan_recognition").innerHTML = Recognition_interim; - if (typeof SpeechRecognition_interim === 'object' && SpeechRecognition_interim !== null) { - if (SpeechRecognition_interim.textContent) - SpeechRecognition_interim.textContent = Recognition_interim; - else if (SpeechRecognition_interim.innerText) - SpeechRecognition_interim.innerText = Recognition_interim; - else if (SpeechRecognition_interim.innerHTML) - SpeechRecognition_interim.innerHTML = Recognition_interim; - else - SpeechRecognition_interim.value = Recognition_interim; - } + if (SpeechRecognition_interim.tagName.toLowerCase()=="input"||SpeechRecognition_interim.tagName.toLowerCase()=="textarea") + SpeechRecognition_interim.value = Recognition_interim; + else + SpeechRecognition_interim.innerHTML = Recognition_interim; //console.log("interim = " + Recognition_interim); }