mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 08:40:38 +00:00
set the detected language as language_code when deepgram detects the language (#1116)
https://github.com/jambonz/jambonz-feature-server/issues/1115
This commit is contained in:
@@ -304,13 +304,18 @@ const normalizeDeepgram = (evt, channel, language, shortUtterance) => {
|
||||
confidence: alt.confidence,
|
||||
transcript: alt.transcript,
|
||||
}));
|
||||
|
||||
/**
|
||||
* Some models (nova-2-general) return the detected language in the
|
||||
* alternatives.languages array if the language is set as multi.
|
||||
* If the language is detected, we use it as the language_code.
|
||||
*/
|
||||
const detectedLanguage = evt.channel?.alternatives?.[0]?.languages?.[0];
|
||||
/**
|
||||
* note difference between is_final and speech_final in Deepgram:
|
||||
* https://developers.deepgram.com/docs/understand-endpointing-interim-results
|
||||
*/
|
||||
return {
|
||||
language_code: language,
|
||||
language_code: detectedLanguage || language,
|
||||
channel_tag: channel,
|
||||
is_final: shortUtterance ? evt.is_final : evt.speech_final,
|
||||
alternatives: alternatives.length ? [alternatives[0]] : [],
|
||||
|
||||
Reference in New Issue
Block a user