【发布时间】:2023-02-19 23:36:53
【问题描述】:
我在我的 NextJS 应用程序中使用标准的 JS 语音识别,它在 Chrome 网络浏览器和 Android 上运行良好。但是当我尝试在 iOS 上的 Chrome 中运行它时它不起作用,但在 Safari 中它运行良好。可能是什么问题?我检查了 Chrome 设置,那里允许访问麦克风。
这是我使用的语音识别方法:
// new speech recognition object
var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition;
var recognition = new SpeechRecognition();
// This runs when the speech recognition service starts
recognition.onstart = function() {
console.log("We are listening. Try speaking into the microphone.");
};
recognition.onspeechend = function() {
// when user is done speaking
recognition.stop();
}
// This runs when the speech recognition service returns result
recognition.onresult = function(event) {
var transcript = event.results[0][0].transcript;
};
// start recognition
recognition.start();
【问题讨论】:
-
确保您已授予网站访问麦克风的必要权限。您可以在您的 iOS 设备上前往“设置”>“隐私”>“麦克风”进行检查。
-
是的,我检查了设置>隐私>麦克风,它可以访问麦克风。
标签: javascript reactjs next.js