add try catch in init speech

This commit is contained in:
akirilyuk
2022-02-26 23:30:12 +01:00
parent 87ef510dea
commit 32ebc7017d

View File

@@ -99,7 +99,7 @@ class TaskGather extends Task {
}
const startListening = (cs, ep) => {
this.logger.info({input: this.input, listenDuringPrompt: this.listenDuringPrompt}, "started listening for speech events via startListening");
this.logger.info({input: this.input, listenDuringPrompt: this.listenDuringPrompt}, 'started listening for speech events via startListening');
this._startTimer();
if (this.input.includes('speech') && !this.listenDuringPrompt) {
this._initSpeech(cs, ep)
@@ -197,7 +197,8 @@ class TaskGather extends Task {
}
async _initSpeech(cs, ep) {
this.logger.info("started listening on speech events initSpeechEnter");
this.logger.info('started listening on speech events initSpeechEnter');
try {
const opts = {};
if (this.vad.enable) {
@@ -258,10 +259,15 @@ class TaskGather extends Task {
ep.addCustomEventListener(AzureTranscriptionEvents.Transcription, this._onTranscription.bind(this, cs, ep));
ep.addCustomEventListener(AzureTranscriptionEvents.NoSpeechDetected, this._onNoSpeechDetected.bind(this, cs, ep));
}
this.logger.info("started listening on speech events initSpeechDone");
this.logger.info('started listening on speech events initSpeechDone');
await ep.set(opts)
.catch((err) => this.logger.info(err, 'Error setting channel variables'));
} catch (err) {
this.logger.error("could not init speech for listening");
}
}
_startTranscribing(ep) {
ep.startTranscription({