简体   繁体   English

如何在不要求麦克风权限的情况下重新启动webkitSpeechRecognition?

[英]How to restart webkitSpeechRecognition without asking for microphone permission?

I used webkitSpeechRecognition to record user voice and using SpeechSynthesisUtterance speaks to the user, however, there has a problem for when the system speaking to the user, it will also record voice. 我使用webkitSpeechRecognition来记录用户语音并使用SpeechSynthesisUtterance对用户说话,但是,当系统对用户说话时,它还会记录语音。

If I stop the recognition and restart, it will ask microphone permission again. 如果我停止识别并重新启动,它将再次询问麦克风许可。 If it has any ideas to pause the recognition and resumed when the speaking is finished? 如果有任何想法暂停识别并在讲话结束后恢复?

or using Recognition.stop() and Recognition.start() without asking microphone permission again? 或者使用Recognition.stop()Recognition.start()而不再询问麦克风权限?

According to MDN theSpeechRecognition API already has those methods: 根据MDN, SpeechRecognition API已经有了这些方法:

SpeechRecognition.abort()

Stops the speech recognition service from listening to incoming audio, and doesn't attempt to return a SpeechRecognitionResult. 停止语音识别服务以收听传入音频,并且不会尝试返回SpeechRecognitionResult。

SpeechRecognition.start()

Starts the speech recognition service listening to incoming audio with intent to recognize grammars associated with the current SpeechRecognition. 启动语音识别服务,听取传入的音频,意图识别与当前SpeechRecognition相关的语法。

SpeechRecognition.stop()

Stops the speech recognition service from listening to incoming audio, and attempts to return a SpeechRecognitionResult using the audio captured so far. 停止语音识别服务以收听传入音频,并尝试使用到目前为止捕获的音频返回SpeechRecognitionResult。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM