Closed xiz2020 closed 2 months ago
Suspend the audio context that is connected to your transferer, ie. call AudioContext.suspend()
to pause. To resume, call AudioContext.resume()
@xiz2020
Here is a demo:
this.utterance.onstart = (e) => {
console.log('Start Speak:', this.audioContext)
if (this.audioContext) {
this.audioContext.suspend()
}
}
this.utterance.onend = (e) => {
console.log('End Speak:', this.audioContext)
if (this.audioContext) {
console.log('Resume Reco');
this.audioContext.resume()
}
}
For some reason I unable to recieve recognized text after: this.audioContext.resume() instruction.
It seems that you're suspending it when starting speak, and resuming it at the end. Maybe I lost some context, but I think it should be the other way around?
I'm using the SpeechSynthesisUtterance interface of the Web Speech API
When TTS is started (Sound from speaker (this.utterance.onstart)) - I need to stop recognition process (this.audioContext.suspend()) - and this seems to be working.
When TTS is ended (this.utterance.onend) - I need to resume recognition from human voice input. And here is a problem: The command - this.audioContext.resume() - doesn't work because I unable to receive recognized text anymore.
Any other ideas to make it possible?
Thanks.
It could be that resume and suspend are asynchronous methods and need awaiting/thening. Usually, this is the best way to stop recognizing because it prevent any processing overhead incurred because the audio stream is blocked. Otherwise, another way would be to unbind/remove the event listener on the transferer and rebind them later
@xiz2020 Could you tell me which way solved it for you?
Do you have a methods for pause recognition and continue?
For example: