Feat/assemblyai testing (#516)

* handle errors from assemblyai

* wip

* fix alert

* normalizeAssemblyai
This commit is contained in:
Dave Horton
2023-11-02 17:05:28 -04:00
committed by GitHub
parent 7fee2ba2dc
commit 6d625d87ad
5 changed files with 68 additions and 35 deletions

View File

@@ -298,8 +298,8 @@ class TaskTranscribe extends SttTask {
this.bugname = 'assemblyai_transcribe';
ep.addCustomEventListener(AssemblyAiTranscriptionEvents.Transcription,
this._onTranscription.bind(this, cs, ep, channel));
ep.addCustomEventListener(AssemblyAiTranscriptionEvents.Connect,
this._onVendorConnect.bind(this, cs, ep));
ep.addCustomEventListener(AssemblyAiTranscriptionEvents.Connect, this._onVendorConnect.bind(this, cs, ep));
ep.addCustomEventListener(AssemblyAiTranscriptionEvents.Error, this._onVendorError.bind(this, cs, ep));
ep.addCustomEventListener(AssemblyAiTranscriptionEvents.ConnectFailure,
this._onVendorConnectFailure.bind(this, cs, ep, channel));
break;
@@ -529,22 +529,8 @@ class TaskTranscribe extends SttTask {
}
}
_onVendorConnect(_cs, _ep) {
this.logger.debug(`TaskTranscribe:_on${this.vendor}Connect`);
}
_onVendorConnectFailure(cs, _ep, channel, evt) {
const {reason} = evt;
const {writeAlerts, AlertType} = cs.srf.locals;
this.logger.info({evt}, `TaskTranscribe:_on${this.vendor}ConnectFailure`);
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 ${this.vendor} connection failure`));
this.notifyError(`Failed connecting to speech vendor ${this.vendor}: ${reason}`);
super._onVendorConnectFailure(cs, _ep, evt);
if (this.childSpan[channel - 1] && this.childSpan[channel - 1].span) {
this.childSpan[channel - 1].span.setAttributes({
channel,
@@ -555,10 +541,6 @@ class TaskTranscribe extends SttTask {
this.notifyTaskDone();
}
_onVendorError(cs, _ep, _channel, vendor, evt) {
this.logger.info({evt}, `TaskTranscribe:_on${vendor}Error`);
}
_startAsrTimer(channel) {
if (this.vendor === 'deepgram') return; // no need
assert(this.isContinuousAsr);