mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
deepgram gather: if both endpointing and utterance_end_ms are set (bu… (#644)
* deepgram gather: if both endpointing and utterance_end_ms are set (but not continous asr) return either when we get speech_final or UtteranceEnd. This is the belt-and-suspenders apprach deepgram is recommending * include verb id in action hook if one was provided in the verb set * minor
This commit is contained in:
@@ -355,9 +355,6 @@ class TaskGather extends SttTask {
|
|||||||
this.addCustomEventListener(ep, DeepgramTranscriptionEvents.Connect, this._onVendorConnect.bind(this, cs, ep));
|
this.addCustomEventListener(ep, DeepgramTranscriptionEvents.Connect, this._onVendorConnect.bind(this, cs, ep));
|
||||||
this.addCustomEventListener(ep, DeepgramTranscriptionEvents.ConnectFailure,
|
this.addCustomEventListener(ep, DeepgramTranscriptionEvents.ConnectFailure,
|
||||||
this._onVendorConnectFailure.bind(this, cs, ep));
|
this._onVendorConnectFailure.bind(this, cs, ep));
|
||||||
|
|
||||||
/* if app sets deepgramOptions.utteranceEndMs they essentially want continuous asr */
|
|
||||||
if (opts.DEEPGRAM_SPEECH_UTTERANCE_END_MS) this.isContinuousAsr = true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'soniox':
|
case 'soniox':
|
||||||
@@ -676,7 +673,7 @@ class TaskGather extends SttTask {
|
|||||||
this.logger.debug({evt, words, bufferedWords},
|
this.logger.debug({evt, words, bufferedWords},
|
||||||
'TaskGather:_onTranscription - final transcript but < min barge words');
|
'TaskGather:_onTranscription - final transcript but < min barge words');
|
||||||
this._bufferedTranscripts.push(evt);
|
this._bufferedTranscripts.push(evt);
|
||||||
this._startTranscribing(ep);
|
if (!['soniox', 'aws', 'microsoft', 'deepgram'].includes(this.vendor)) this._startTranscribing(ep);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -689,17 +686,11 @@ class TaskGather extends SttTask {
|
|||||||
else if (this.vendor === 'deepgram') {
|
else if (this.vendor === 'deepgram') {
|
||||||
/* compile transcripts into one */
|
/* compile transcripts into one */
|
||||||
if (!emptyTranscript) this._bufferedTranscripts.push(evt);
|
if (!emptyTranscript) this._bufferedTranscripts.push(evt);
|
||||||
if (this.data.recognizer?.deepgramOptions?.utteranceEndMs) {
|
|
||||||
this.logger.debug('TaskGather:_onTranscription - got speech_final waiting for UtteranceEnd event');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* deepgram can send an empty and final transcript; only if we have any buffered should we resolve */
|
/* deepgram can send an empty and final transcript; only if we have any buffered should we resolve */
|
||||||
if (this._bufferedTranscripts.length === 0) return;
|
if (this._bufferedTranscripts.length === 0) return;
|
||||||
this.logger.debug({evt}, 'TaskGather:_onTranscription - compiling deepgram transcripts');
|
|
||||||
evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language);
|
evt = this.consolidateTranscripts(this._bufferedTranscripts, 1, this.language);
|
||||||
this._bufferedTranscripts = [];
|
this._bufferedTranscripts = [];
|
||||||
this.logger.debug({evt}, 'TaskGather:_onTranscription - compiled deepgram transcripts');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* here is where we return a final transcript */
|
/* here is where we return a final transcript */
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ class Task extends Emitter {
|
|||||||
const httpHeaders = b3 && {b3};
|
const httpHeaders = b3 && {b3};
|
||||||
span.setAttributes({'http.body': JSON.stringify(params)});
|
span.setAttributes({'http.body': JSON.stringify(params)});
|
||||||
try {
|
try {
|
||||||
|
if (this.id) params.verb_id = this.id;
|
||||||
const json = await this.cs.requestor.request(type, this.actionHook, params, httpHeaders);
|
const json = await this.cs.requestor.request(type, this.actionHook, params, httpHeaders);
|
||||||
span.setAttributes({'http.statusCode': 200});
|
span.setAttributes({'http.statusCode': 200});
|
||||||
const isWsConnection = this.cs.requestor instanceof WsRequestor;
|
const isWsConnection = this.cs.requestor instanceof WsRequestor;
|
||||||
|
|||||||
Reference in New Issue
Block a user