mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2026-10-04 02:04:12 +00:00
Fix/flux cleanup (#1379)
* for deepgram flux include the turn taking events in the transcription payload * for deepgram flux, including turn_taking_event in the speech payload * fix prev commit which used wrong field
This commit is contained in:
@@ -339,16 +339,28 @@ const normalizeDeepgram = (evt, channel, language, shortUtterance) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const normalizeDeepgramFlux = (evt, channel, language, shortUtterance) => {
|
const normalizeDeepgramFlux = (evt, channel, language) => {
|
||||||
const copy = JSON.parse(JSON.stringify(evt));
|
const copy = JSON.parse(JSON.stringify(evt));
|
||||||
|
|
||||||
|
let turnTakingEvent;
|
||||||
|
if (['StartOfTurn', 'EagerEndOfTurn', 'TurnResumed', 'EndOfTurn'].includes(evt.event)) {
|
||||||
|
turnTakingEvent = evt.event;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate total confidence based on word-level confidence */
|
||||||
|
const realWords = (evt.words || [])
|
||||||
|
.filter((w) => ![',.!?;'].includes(w.word));
|
||||||
|
const confidence = realWords.length > 0 ? realWords.reduce((acc, w) => acc + w.confidence, 0) / realWords.length : 0;
|
||||||
return {
|
return {
|
||||||
language_code: language,
|
language_code: language,
|
||||||
channel_tag: channel,
|
channel_tag: channel,
|
||||||
is_final: evt.event === 'EndOfTurn',
|
is_final: evt.event === 'EndOfTurn',
|
||||||
alternatives: [
|
alternatives: [
|
||||||
{
|
{
|
||||||
confidence: evt.end_of_turn_confidence,
|
confidence,
|
||||||
|
end_of_turn_confidence: evt.end_of_turn_confidence,
|
||||||
transcript: evt.transcript,
|
transcript: evt.transcript,
|
||||||
|
...(turnTakingEvent && {turn_taking_event: turnTakingEvent})
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
vendor: {
|
vendor: {
|
||||||
@@ -967,7 +979,6 @@ module.exports = (logger) => {
|
|||||||
}
|
}
|
||||||
else if ('deepgramflux' === vendor) {
|
else if ('deepgramflux' === vendor) {
|
||||||
const {
|
const {
|
||||||
preflightThreshold,
|
|
||||||
eotThreshold,
|
eotThreshold,
|
||||||
eotTimeoutMs,
|
eotTimeoutMs,
|
||||||
mipOptOut,
|
mipOptOut,
|
||||||
@@ -978,7 +989,6 @@ module.exports = (logger) => {
|
|||||||
opts = {
|
opts = {
|
||||||
DEEPGRAMFLUX_API_KEY: sttCredentials.api_key,
|
DEEPGRAMFLUX_API_KEY: sttCredentials.api_key,
|
||||||
DEEPGRAMFLUX_SPEECH_MODEL: model || 'flux-general-en',
|
DEEPGRAMFLUX_SPEECH_MODEL: model || 'flux-general-en',
|
||||||
...(preflightThreshold && {DEEPGRAMFLUX_SPEECH_PRELIGHT_THRESHOLD: preflightThreshold}),
|
|
||||||
...(eotThreshold && {DEEPGRAMFLUX_SPEECH_EOT_THRESHOLD: eotThreshold}),
|
...(eotThreshold && {DEEPGRAMFLUX_SPEECH_EOT_THRESHOLD: eotThreshold}),
|
||||||
...(eotTimeoutMs && {DEEPGRAMFLUX_SPEECH_EOT_TIMEOUT_MS: eotTimeoutMs}),
|
...(eotTimeoutMs && {DEEPGRAMFLUX_SPEECH_EOT_TIMEOUT_MS: eotTimeoutMs}),
|
||||||
...(mipOptOut && {DEEPGRAMFLUX_SPEECH_MIP_OPT_OUT: mipOptOut}),
|
...(mipOptOut && {DEEPGRAMFLUX_SPEECH_MIP_OPT_OUT: mipOptOut}),
|
||||||
|
|||||||
Generated
+4
-5
@@ -18,7 +18,7 @@
|
|||||||
"@jambonz/speech-utils": "^0.2.24",
|
"@jambonz/speech-utils": "^0.2.24",
|
||||||
"@jambonz/stats-collector": "^0.1.10",
|
"@jambonz/stats-collector": "^0.1.10",
|
||||||
"@jambonz/time-series": "^0.2.14",
|
"@jambonz/time-series": "^0.2.14",
|
||||||
"@jambonz/verb-specifications": "^0.0.115",
|
"@jambonz/verb-specifications": "^0.0.116",
|
||||||
"@modelcontextprotocol/sdk": "^1.9.0",
|
"@modelcontextprotocol/sdk": "^1.9.0",
|
||||||
"@opentelemetry/api": "^1.8.0",
|
"@opentelemetry/api": "^1.8.0",
|
||||||
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
||||||
@@ -1520,10 +1520,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@jambonz/verb-specifications": {
|
"node_modules/@jambonz/verb-specifications": {
|
||||||
"version": "0.0.115",
|
"version": "0.0.116",
|
||||||
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.115.tgz",
|
"resolved": "https://registry.npmjs.org/@jambonz/verb-specifications/-/verb-specifications-0.0.116.tgz",
|
||||||
"integrity": "sha512-T2J5skCZBADaxePkFqpm0JYwr5Iu6e9zgvk6j0/4vD6lwK29GSoSdk2LCKUY6VH2GYdaN6r3dyIw4xpFVXuMfQ==",
|
"integrity": "sha512-EFAtwSpSWA12nk7eQfAiWS0bGkCA5+NqKsylnVIXNWuSjRZ5wTS0dAZZZxqtZxPZ1DxdBLCafbLsKZJ4fkC+tQ==",
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"pino": "^8.8.0"
|
"pino": "^8.8.0"
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@
|
|||||||
"@jambonz/speech-utils": "^0.2.24",
|
"@jambonz/speech-utils": "^0.2.24",
|
||||||
"@jambonz/stats-collector": "^0.1.10",
|
"@jambonz/stats-collector": "^0.1.10",
|
||||||
"@jambonz/time-series": "^0.2.14",
|
"@jambonz/time-series": "^0.2.14",
|
||||||
"@jambonz/verb-specifications": "^0.0.115",
|
"@jambonz/verb-specifications": "^0.0.116",
|
||||||
"@modelcontextprotocol/sdk": "^1.9.0",
|
"@modelcontextprotocol/sdk": "^1.9.0",
|
||||||
"@opentelemetry/api": "^1.8.0",
|
"@opentelemetry/api": "^1.8.0",
|
||||||
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
"@opentelemetry/exporter-jaeger": "^1.23.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user