Allow Say, Gather, Transcribe is able to finished if there is error for speech credential (#910)

* allow move to next task if say verb is failed because of speech credential

* allow move to next task if say verb is failed because of speech credential

* allow move to next task if say verb is failed because of speech credential

* wip

* wip
This commit is contained in:
Hoan Luu Huu
2024-10-02 00:40:41 +07:00
committed by GitHub
parent b898b70520
commit 96b3b0fe07
6 changed files with 65 additions and 8 deletions

View File

@@ -22,6 +22,7 @@ const {
const makeTask = require('./make_task');
const assert = require('assert');
const SttTask = require('./stt-task');
const { SpeechCredentialError } = require('../utils/error');
class TaskGather extends SttTask {
constructor(logger, opts, parentTask) {
@@ -122,7 +123,20 @@ class TaskGather extends SttTask {
return s;
}
async exec(cs, {ep}) {
async exec(cs, obj) {
try {
await this.handling(cs, obj);
} catch (error) {
if (error instanceof SpeechCredentialError) {
this.logger.info('Gather failed due to SpeechCredentialError, finished!');
this.notifyTaskDone();
return;
}
throw error;
}
}
async handling(cs, {ep}) {
this.logger.debug({options: this.data}, 'Gather:exec');
await super.exec(cs, {ep});
const {updateSpeechCredentialLastUsed} = require('../utils/db-utils')(this.logger, cs.srf);