首页 > 解决方案 > mac Safari 上的 SpeechRecognition 事件监听器

问题描述

我正在使用 Web API SpeechRecognition 构建应用程序,但 onspeechstart 和 onspeechend 侦听器不起作用。 https://developer.mozilla.org/ja/docs/Web/API/SpeechRecognition

Safari 的版本是 15.0。

相关代码如下。语言是打字稿(javascript)。

const SpeechRecognitionrecognition = (window as any).webkitSpeechRecognition;
speechRecognizer = new SpeechRecognitionrecognition();
speechRecognizer.onspeechstart = () => {
  // Process when the user starts speaking
};
speechRecognizer.onspeechend = () => {
  // Processing when speech is finished
};

在 Safari 中使用这些事件侦听器是否需要任何设置?如果您对此有所了解,如果您能告诉我,我将不胜感激。

标签: javascriptsafariwebkitspeechrecognition

解决方案


推荐阅读