mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
feat fast recognition (#461)
* feat fast recognition * don't use buffer transcript for fast recognition * update verb specification * fix merge conflict --------- Co-authored-by: Dave Horton <daveh@beachdognet.com>
This commit is contained in:
@@ -59,6 +59,9 @@ class TaskGather extends SttTask {
|
||||
logger.debug('Gather: an empty hints array was supplied, so we will mask global hints');
|
||||
this.maskGlobalSttHints = true;
|
||||
}
|
||||
// fast Recognition, fire event after a specified time after the last hypothesis.
|
||||
this.fastRecognitionTimeout = typeof this.data.recognizer.fastRecognitionTimeout === 'number' ?
|
||||
this.data.recognizer.fastRecognitionTimeout * 1000 : 0;
|
||||
}
|
||||
|
||||
this.digitBuffer = '';
|
||||
@@ -520,6 +523,22 @@ class TaskGather extends SttTask {
|
||||
this._asrTimer = null;
|
||||
}
|
||||
|
||||
_startFastRecognitionTimer(evt) {
|
||||
assert(this.fastRecognitionTimeout > 0);
|
||||
this._clearFastRecognitionTimer();
|
||||
this._fastRecognitionTimer = setTimeout(() => {
|
||||
evt.is_final = true;
|
||||
this._resolve('speech', evt);
|
||||
}, this.fastRecognitionTimeout);
|
||||
}
|
||||
|
||||
_clearFastRecognitionTimer() {
|
||||
if (this._fastRecognitionTimer) {
|
||||
clearTimeout(this._fastRecognitionTimer);
|
||||
}
|
||||
this._fastRecognitionTimer = null;
|
||||
}
|
||||
|
||||
_startFinalAsrTimer() {
|
||||
this._clearFinalAsrTimer();
|
||||
this._finalAsrTimer = setTimeout(() => {
|
||||
@@ -657,6 +676,9 @@ class TaskGather extends SttTask {
|
||||
}
|
||||
this._killAudio(cs);
|
||||
}
|
||||
if (this.fastRecognitionTimeout) {
|
||||
this._startFastRecognitionTimer(evt);
|
||||
}
|
||||
if (this.partialResultHook) {
|
||||
const b3 = this.getTracingPropagation();
|
||||
const httpHeaders = b3 && {b3};
|
||||
@@ -821,6 +843,7 @@ class TaskGather extends SttTask {
|
||||
}
|
||||
clearTimeout(this.interDigitTimer);
|
||||
this._clearTimer();
|
||||
this._clearFastRecognitionTimer();
|
||||
|
||||
if (this.isContinuousAsr && reason.startsWith('speech')) {
|
||||
evt = {
|
||||
|
||||
Reference in New Issue
Block a user