mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
Co-authored-by: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com>
This commit is contained in:
@@ -234,7 +234,19 @@ class TaskTranscribe extends Task {
|
|||||||
this._onVadDetected.bind(this, cs, ep));
|
this._onVadDetected.bind(this, cs, ep));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Invalid vendor ${this.vendor}`);
|
if (this.vendor.startsWith('custom:')) {
|
||||||
|
this.bugname = `${this.vendor}_transcribe`;
|
||||||
|
ep.addCustomEventListener(JambonzTranscriptionEvents.Transcription, this._onTranscription.bind(this, cs, ep));
|
||||||
|
ep.addCustomEventListener(JambonzTranscriptionEvents.Connect, this._onJambonzConnect.bind(this, cs, ep));
|
||||||
|
ep.addCustomEventListener(JambonzTranscriptionEvents.ConnectFailure,
|
||||||
|
this._onJambonzConnectFailure.bind(this, cs, ep));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.notifyError({ msg: 'ASR error', details:`Invalid vendor ${this.vendor}`});
|
||||||
|
this.notifyTaskDone();
|
||||||
|
throw new Error(`Invalid vendor ${this.vendor}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* common handler for all stt engine errors */
|
/* common handler for all stt engine errors */
|
||||||
@@ -408,6 +420,24 @@ class TaskTranscribe extends Task {
|
|||||||
this.notifyTaskDone();
|
this.notifyTaskDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onJambonzConnect(_cs, _ep) {
|
||||||
|
this.logger.debug('TaskTranscribe:_onJambonzConnect');
|
||||||
|
}
|
||||||
|
|
||||||
|
_onJambonzConnectFailure(cs, _ep, evt) {
|
||||||
|
const {reason} = evt;
|
||||||
|
const {writeAlerts, AlertType} = cs.srf.locals;
|
||||||
|
this.logger.info({evt}, 'TaskTranscribe:_onJambonzConnectFailure');
|
||||||
|
writeAlerts({
|
||||||
|
account_sid: cs.accountSid,
|
||||||
|
alert_type: AlertType.STT_FAILURE,
|
||||||
|
message: `Failed connecting to ${this.vendor} speech recognizer: ${reason}`,
|
||||||
|
vendor: this.vendor,
|
||||||
|
}).catch((err) => this.logger.info({err}, 'Error generating alert for jambonz custom connection failure'));
|
||||||
|
this.notifyError({msg: 'ASR error', details:`Failed connecting to speech vendor ${this.vendor}: ${reason}`});
|
||||||
|
this.notifyTaskDone();
|
||||||
|
}
|
||||||
|
|
||||||
_onIbmConnect(_cs, _ep) {
|
_onIbmConnect(_cs, _ep) {
|
||||||
this.logger.debug('TaskTranscribe:_onIbmConnect');
|
this.logger.debug('TaskTranscribe:_onIbmConnect');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user