mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
support stt latency metrics (#1252)
* support stt latency metrics * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * enable stt latency calculator by config verb * wip * wip * wip * fix jslint * fixed gather timeout does not have latency calculation * upadte verb specification to use notifySttLatency * move stt latency metric from call session to stt-latency calculator * wip
This commit is contained in:
@@ -38,6 +38,7 @@ const BADPRECONDITIONS = 'preconditions not met';
|
||||
const CALLER_CANCELLED_ERR_MSG = 'Response not sent due to unknown transaction';
|
||||
const { NonFatalTaskError} = require('../utils/error');
|
||||
const { createMediaEndpoint } = require('../utils/media-endpoint');
|
||||
const SttLatencyCalculator = require('../utils/stt-latency-calculator');
|
||||
const sqlRetrieveQueueEventHook = `SELECT * FROM webhooks
|
||||
WHERE webhook_sid =
|
||||
(
|
||||
@@ -147,6 +148,30 @@ class CallSession extends Emitter {
|
||||
this.conversationTurns = [];
|
||||
this.on('userSaid', this._onUserSaid.bind(this));
|
||||
this.on('botSaid', this._onBotSaid.bind(this));
|
||||
/**
|
||||
* Support STT latency
|
||||
*/
|
||||
this.sttLatencyCalculator = new SttLatencyCalculator({
|
||||
logger,
|
||||
cs: this
|
||||
});
|
||||
this.on('transcribe-start', () => {
|
||||
this.sttLatencyCalculator.resetTime();
|
||||
});
|
||||
this.on('on-transcription', () => {
|
||||
this.sttLatencyCalculator.onTranscriptionReceived();
|
||||
});
|
||||
this.on('transcribe-stop', () => {
|
||||
this.sttLatencyCalculator.onTranscribeStop();
|
||||
});
|
||||
}
|
||||
|
||||
get notifySttLatencyEnabled() {
|
||||
return this._notifySttLatencyEnabled || false;
|
||||
}
|
||||
|
||||
set notifySttLatencyEnabled(enabled) {
|
||||
this._notifySttLatencyEnabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2480,6 +2505,8 @@ Duration=${duration} `
|
||||
this.clearOrRestoreActionHookDelayProcessor().catch((err) => {});
|
||||
|
||||
this.ttsStreamingBuffer?.stop();
|
||||
|
||||
this.sttLatencyCalculator?.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3127,6 +3154,20 @@ Duration=${duration} `
|
||||
return `assistant: ${t.text}`;
|
||||
}).join('\n');
|
||||
}
|
||||
|
||||
startSttLatencyVad() {
|
||||
if (this.notifySttLatencyEnabled) {
|
||||
this.sttLatencyCalculator.start();
|
||||
}
|
||||
}
|
||||
|
||||
stopSttLatencyVad() {
|
||||
this.sttLatencyCalculator.stop();
|
||||
}
|
||||
|
||||
calculateSttLatency() {
|
||||
return this.sttLatencyCalculator.calculateLatency();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CallSession;
|
||||
|
||||
Reference in New Issue
Block a user