mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
wip
This commit is contained in:
@@ -70,6 +70,9 @@ class TaskTranscribe extends SttTask {
|
||||
this._bufferedTranscripts = [ [], [] ]; // for channel 1 and 2
|
||||
this.bugname_prefix = 'transcribe_';
|
||||
this.paused = false;
|
||||
// fallback flags
|
||||
this.isHandledByPrimaryProviderForEp1 = true;
|
||||
this.isHandledByPrimaryProviderForEp2 = true;
|
||||
}
|
||||
|
||||
get name() { return TaskName.Transcribe; }
|
||||
@@ -776,7 +779,7 @@ class TaskTranscribe extends SttTask {
|
||||
}
|
||||
|
||||
async _startFallback(cs, _ep, evt) {
|
||||
if (this.canFallback) {
|
||||
if (this.canFallback(_ep)) {
|
||||
_ep.stopTranscription({
|
||||
vendor: this.vendor,
|
||||
bugname: this.bugname,
|
||||
@@ -895,6 +898,25 @@ class TaskTranscribe extends SttTask {
|
||||
if (this._asrTimer) clearTimeout(this._asrTimer);
|
||||
this._asrTimer = null;
|
||||
}
|
||||
|
||||
// We need to keep track the fallback is happened for each endpoint
|
||||
// override the canFallback and _initFallback methods to make sure that
|
||||
// we only fallback once per endpoint
|
||||
canFallback(ep) {
|
||||
const isHandledByPrimaryProvider = ep === this.ep ?
|
||||
this.isHandledByPrimaryProviderForEp1 : ep === this.ep2 ?
|
||||
this.isHandledByPrimaryProviderForEp2 : false;
|
||||
return this.fallbackVendor && isHandledByPrimaryProvider && !this.cs.hasFallbackAsr;
|
||||
}
|
||||
|
||||
_initFallback(ep) {
|
||||
if (ep === this.ep) {
|
||||
this.isHandledByPrimaryProviderForEp1 = false;
|
||||
} else if (ep === this.ep2) {
|
||||
this.isHandledByPrimaryProviderForEp2 = false;
|
||||
}
|
||||
return super._initFallback(ep);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TaskTranscribe;
|
||||
|
||||
Reference in New Issue
Block a user