mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
fixed transcribe cannot fallback for specific endpoint
This commit is contained in:
@@ -260,8 +260,19 @@ class SttTask extends Task {
|
|||||||
ep.addCustomEventListener(event, handler);
|
ep.addCustomEventListener(event, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeCustomEventListeners() {
|
removeCustomEventListeners(ep) {
|
||||||
|
if (ep) {
|
||||||
|
// for specific endpoint
|
||||||
|
this.eventHandlers.filter((h) => h.ep === ep).forEach((h) => {
|
||||||
|
h.ep.removeCustomEventListener(h.event, h.handler);
|
||||||
|
});
|
||||||
|
this.eventHandlers = this.eventHandlers.filter((h) => h.ep !== ep);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// for all endpoints
|
||||||
this.eventHandlers.forEach((h) => h.ep.removeCustomEventListener(h.event, h.handler));
|
this.eventHandlers.forEach((h) => h.ep.removeCustomEventListener(h.event, h.handler));
|
||||||
|
this.eventHandlers = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _initSpeechCredentials(cs, vendor, label) {
|
async _initSpeechCredentials(cs, vendor, label) {
|
||||||
@@ -333,7 +344,8 @@ class SttTask extends Task {
|
|||||||
return this.fallbackVendor && this.isHandledByPrimaryProvider && !this.cs.hasFallbackAsr;
|
return this.fallbackVendor && this.isHandledByPrimaryProvider && !this.cs.hasFallbackAsr;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _initFallback() {
|
// gather does not need to provide ep, but transcribe does as it might has 2 legs
|
||||||
|
async _initFallback(ep) {
|
||||||
assert(this.fallbackVendor, 'fallback failed without fallbackVendor configuration');
|
assert(this.fallbackVendor, 'fallback failed without fallbackVendor configuration');
|
||||||
this.logger.info(`Failed to use primary STT provider, fallback to ${this.fallbackVendor}`);
|
this.logger.info(`Failed to use primary STT provider, fallback to ${this.fallbackVendor}`);
|
||||||
this.isHandledByPrimaryProvider = false;
|
this.isHandledByPrimaryProvider = false;
|
||||||
@@ -346,7 +358,7 @@ class SttTask extends Task {
|
|||||||
this.data.recognizer.label = this.label;
|
this.data.recognizer.label = this.label;
|
||||||
this.sttCredentials = await this._initSpeechCredentials(this.cs, this.vendor, this.label);
|
this.sttCredentials = await this._initSpeechCredentials(this.cs, this.vendor, this.label);
|
||||||
// cleanup previous listener from previous vendor
|
// cleanup previous listener from previous vendor
|
||||||
this.removeCustomEventListeners();
|
this.removeCustomEventListeners(ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
async compileHintsForCobalt(ep, hostport, model, token, hints) {
|
async compileHintsForCobalt(ep, hostport, model, token, hints) {
|
||||||
|
|||||||
@@ -786,7 +786,7 @@ class TaskTranscribe extends SttTask {
|
|||||||
try {
|
try {
|
||||||
this.notifyError({ msg: 'ASR error',
|
this.notifyError({ msg: 'ASR error',
|
||||||
details:`STT Vendor ${this.vendor} error: ${evt.error || evt.reason}`, failover: 'in progress'});
|
details:`STT Vendor ${this.vendor} error: ${evt.error || evt.reason}`, failover: 'in progress'});
|
||||||
await this._initFallback();
|
await this._initFallback(_ep);
|
||||||
let channel = 1;
|
let channel = 1;
|
||||||
if (this.ep !== _ep) {
|
if (this.ep !== _ep) {
|
||||||
channel = 2;
|
channel = 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user