mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 17:17:58 +00:00
feature: return transcript faster if we get an exact match to a provided hint on an interim transcript (requires env JAMBONZ_GATHER_EARLY_HINTS_MATCH=1)
This commit is contained in:
@@ -143,6 +143,14 @@ class TaskGather extends Task {
|
|||||||
this.logger.debug({hints: this.hints, hintsBoost: this.hintsBoost},
|
this.logger.debug({hints: this.hints, hintsBoost: this.hintsBoost},
|
||||||
'Gather:exec - applying global sttHints');
|
'Gather:exec - applying global sttHints');
|
||||||
}
|
}
|
||||||
|
if (process.env.JAMBONZ_GATHER_EARLY_HINTS_MATCH &&
|
||||||
|
!this.isContinuousAsr &&
|
||||||
|
this.hints.length > 0 && this.hints.length <= 10) {
|
||||||
|
this.earlyHintsMatch = true;
|
||||||
|
this.interim = true;
|
||||||
|
this.logger.debug('Gather:exec - early hints match enabled');
|
||||||
|
}
|
||||||
|
|
||||||
if (cs.hasAltLanguages) {
|
if (cs.hasAltLanguages) {
|
||||||
this.altLanguages = this.altLanguages.concat(cs.altLanguages);
|
this.altLanguages = this.altLanguages.concat(cs.altLanguages);
|
||||||
this.logger.debug({altLanguages: this.altLanguages},
|
this.logger.debug({altLanguages: this.altLanguages},
|
||||||
@@ -526,6 +534,15 @@ class TaskGather extends Task {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.earlyHintsMatch && evt.is_final === false) {
|
||||||
|
const transcript = evt.alternatives[0].transcript?.toLowerCase();
|
||||||
|
if (this.hints.find((h) => h.toLowerCase() === transcript)) {
|
||||||
|
this.logger.debug({evt}, 'Gather:_onTranscription: early hint match');
|
||||||
|
this._resolve('speech', evt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* count words for bargein feature */
|
/* count words for bargein feature */
|
||||||
const words = evt.alternatives[0].transcript.split(' ').length;
|
const words = evt.alternatives[0].transcript.split(' ').length;
|
||||||
const bufferedWords = this._bufferedTranscripts.reduce((count, e) => {
|
const bufferedWords = this._bufferedTranscripts.reduce((count, e) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user