简体   繁体   中英

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.

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?

According to MDN theSpeechRecognition API already has those methods:

SpeechRecognition.abort()

Stops the speech recognition service from listening to incoming audio, and doesn't attempt to return a SpeechRecognitionResult.

SpeechRecognition.start()

Starts the speech recognition service listening to incoming audio with intent to recognize grammars associated with the current 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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