mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 17:17:58 +00:00
rework min barge in to require >min in one utterance
This commit is contained in:
@@ -515,10 +515,6 @@ class TaskGather extends Task {
|
|||||||
|
|
||||||
/* 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) => {
|
|
||||||
return count + e.alternatives[0].transcript.split(' ').length;
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
if (evt.is_final) {
|
if (evt.is_final) {
|
||||||
if (evt.alternatives[0].transcript === '' && !this.callSession.callGone && !this.killed) {
|
if (evt.alternatives[0].transcript === '' && !this.callSession.callGone && !this.killed) {
|
||||||
if ('microsoft' === this.vendor && finished === 'true') {
|
if ('microsoft' === this.vendor && finished === 'true') {
|
||||||
@@ -549,14 +545,14 @@ class TaskGather extends Task {
|
|||||||
return this._resolve(this._bufferedTranscripts.length > 0 ? 'speech' : 'timeout');
|
return this._resolve(this._bufferedTranscripts.length > 0 ? 'speech' : 'timeout');
|
||||||
}
|
}
|
||||||
this._startAsrTimer();
|
this._startAsrTimer();
|
||||||
return this._startTranscribing(ep);
|
if ('microsoft' !== this.vendor) this._startTranscribing(ep);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.bargein && (words + bufferedWords) < this.minBargeinWordCount) {
|
if (this.bargein && words < this.minBargeinWordCount) {
|
||||||
this.logger.debug({evt, words, bufferedWords},
|
this.logger.debug({evt},
|
||||||
'TaskGather:_onTranscription - final transcript but < min barge words');
|
`TaskGather:_onTranscription - got ${words} but minBargein is ${this.minBargeinWordCount}; discarding`);
|
||||||
this._bufferedTranscripts.push(evt);
|
if ('microsoft' !== this.vendor) this._startTranscribing(ep);
|
||||||
this._startTranscribing(ep);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -570,9 +566,9 @@ class TaskGather extends Task {
|
|||||||
others do not.
|
others do not.
|
||||||
*/
|
*/
|
||||||
//const isStableEnough = typeof evt.stability === 'undefined' || evt.stability > GATHER_STABILITY_THRESHOLD;
|
//const isStableEnough = typeof evt.stability === 'undefined' || evt.stability > GATHER_STABILITY_THRESHOLD;
|
||||||
if (this.bargein && (words + bufferedWords) >= this.minBargeinWordCount) {
|
if (this.bargein && words >= this.minBargeinWordCount) {
|
||||||
if (!this.playComplete) {
|
if (!this.playComplete) {
|
||||||
this.logger.debug({transcript: evt.alternatives[0].transcript}, 'killing audio due to speech');
|
this.logger.debug({transcript: evt.alternatives[0].transcript}, 'killing audio due to minBargein words');
|
||||||
this.emit('vad');
|
this.emit('vad');
|
||||||
}
|
}
|
||||||
this._killAudio(cs);
|
this._killAudio(cs);
|
||||||
|
|||||||
Reference in New Issue
Block a user