检查用户是否插入了麦克风

时间:2016-03-23 21:51:11

标签: javascript speech-recognition microphone

我有一个功能可以检查浏览器是否支持语音识别,并且它会警告它是否支持,并且它运行良好,但它不会在用户使用谷歌浏览器时发出任何警报,但是没有插入麦克风。

我希望检查一下用户是否插入了麦克风。那可能吗?

function recognize() {

window.speechRecognition = window.speechRecognition || window.webkitSpeechRecognition || window.mozSpeechRecognition || window.webkitSpeechRecognition;

if (window.speechRecognition == undefined) { 
alert("Speech Recognition Only Supported in Google Chrome"); 
} //end of if (window.speechRecognition == undefined)
else {
alert("Speech Recognition is Supported.");
} //end of else if (window.speechRecognition != undefined)

} //end of function recognize()

1 个答案:

答案 0 :(得分:3)

$ awk -v RS="\n}\n}" 'NR==1{term=RT}
                           {a[NR]=$0}
           END{for(i=1;i<NR;i++) 
                  for(k=1;k<=i;k++) 
                     print a[k] term > FILENAME"_"i}' file