From b3f37366287c96d5e0c8100a70fb60551ece823c Mon Sep 17 00:00:00 2001 From: xquanluu Date: Sun, 24 May 2026 13:45:49 +0700 Subject: [PATCH] wip --- lib/tasks/gather.js | 17 +++++++---------- lib/tasks/transcribe.js | 19 ++++++++----------- lib/utils/constants.json | 3 +-- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/lib/tasks/gather.js b/lib/tasks/gather.js index cff5fd12..0ada516a 100644 --- a/lib/tasks/gather.js +++ b/lib/tasks/gather.js @@ -593,8 +593,6 @@ class TaskGather extends SttTask { this._onVendorConnectFailure.bind(this, cs, ep)); this.addCustomEventListener(ep, HoundifyTranscriptionEvents.Connect, this._onVendorConnect.bind(this, cs, ep)); - this.addCustomEventListener(ep, HoundifyTranscriptionEvents.EoqVadTriggered, - this._onHoundifyEoqVadTriggered.bind(this, cs, ep)); break; case 'voxist': @@ -762,13 +760,6 @@ class TaskGather extends SttTask { return false; } - /* houndify mode=none: FS detected eoq/vad — send Done now if asrTimeout=0, else arm asrTimer. */ - _onHoundifyEoqVadTriggered(_cs, _ep, _evt, _fsEvent) { - if (!this.asrTimeout) return this._sendHoundifyDone(this.ep); - if (this._asrTimer) return; - this._startAsrTimer(); - } - _startAsrTimer() { // Deepgram has a case that UtteranceEnd is not sent to cover the last word end time. // So we need to wait for the asrTimeout to be sure that the last word is sent. @@ -1122,8 +1113,14 @@ class TaskGather extends SttTask { if (!this.asrTimeout) this._sendHoundifyDone(this.ep); else this._startAsrTimer(); } else if (transcript) { - /* mode segmentation OFF: track last non-empty partial */ + /* mode segmentation OFF: FS module filters partials by eoq/vad threshold, + * so any partial arriving here is an end-of-turn signal. */ this._houndifyLastPartial = evt; + const segMode = this.data.recognizer?.houndifyOptions?.requestInfo?.segmentation?.mode !== 'none'; + if (!segMode) { + if (!this.asrTimeout) this._sendHoundifyDone(this.ep); + else this._startAsrTimer(); + } } if (!transcript) emptyTranscript = true; } diff --git a/lib/tasks/transcribe.js b/lib/tasks/transcribe.js index e55ad04d..2ed496ed 100644 --- a/lib/tasks/transcribe.js +++ b/lib/tasks/transcribe.js @@ -353,8 +353,6 @@ class TaskTranscribe extends SttTask { this._onVendorConnectFailure.bind(this, cs, ep, channel)); this.addCustomEventListener(ep, HoundifyTranscriptionEvents.Connect, this._onVendorConnect.bind(this, cs, ep)); - this.addCustomEventListener(ep, HoundifyTranscriptionEvents.EoqVadTriggered, - this._onHoundifyEoqVadTriggered.bind(this, cs, ep, channel)); break; case 'voxist': @@ -654,9 +652,16 @@ class TaskTranscribe extends SttTask { if (!this.asrTimeout) this._sendHoundifyDone(channel === 2 ? this.ep2 : this.ep, channel); else this._startAsrTimer(channel); } else if (transcript) { - /* mode segmentation OFF: track last non-empty partial per channel */ + /* mode segmentation OFF: FS module filters partials by eoq/vad threshold, + * so any partial arriving here is an end-of-turn signal. */ this._houndifyLastPartial = this._houndifyLastPartial || [null, null]; this._houndifyLastPartial[channel - 1] = evt; + const segMode = this.data.recognizer?.houndifyOptions?.requestInfo?.segmentation?.mode !== 'none'; + if (!segMode) { + const ep = channel === 2 ? this.ep2 : this.ep; + if (!this.asrTimeout) this._sendHoundifyDone(ep, channel); + else this._startAsrTimer(channel); + } } } @@ -936,14 +941,6 @@ class TaskTranscribe extends SttTask { this._onVendorError(cs, _ep, {error: JSON.stringify(e)}); } - /* houndify mode=none: FS detected eoq/vad — send Done now if asrTimeout=0, else arm asrTimer. */ - _onHoundifyEoqVadTriggered(_cs, _ep, channel, _evt, _fsEvent) { - const ep = channel === 2 ? this.ep2 : this.ep; - if (!this.asrTimeout) return this._sendHoundifyDone(ep, channel); - if (this._asrTimers?.[channel - 1]) return; /* idempotent per channel */ - this._startAsrTimer(channel); - } - _startAsrTimer(channel) { if (this.vendor === 'deepgram') return; // no need assert(this.isContinuousAsr || this.vendor === 'houndify'); diff --git a/lib/utils/constants.json b/lib/utils/constants.json index 746f420f..89203ac2 100644 --- a/lib/utils/constants.json +++ b/lib/utils/constants.json @@ -179,8 +179,7 @@ "Transcription": "houndify_transcribe::transcription", "Error": "houndify_transcribe::error", "ConnectFailure": "houndify_transcribe::connect_failed", - "Connect": "houndify_transcribe::connect", - "EoqVadTriggered": "houndify_transcribe::eoq_vad_triggered" + "Connect": "houndify_transcribe::connect" }, "VoxistTranscriptionEvents": { "Transcription": "voxist_transcribe::transcription",