mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
set default deepgram model by language and task (gather vs transcribe) (#610)
* set default deepgram model by language and task (gather vs transcribe) * wip
This commit is contained in:
@@ -266,7 +266,7 @@ module.exports = (logger) => {
|
||||
|
||||
/* set stt options */
|
||||
logger.info(`starting amd for vendor ${vendor} and language ${language}`);
|
||||
const sttOpts = amd.setChannelVarsForStt({name: TaskName.Gather}, sttCredentials, {
|
||||
const sttOpts = amd.setChannelVarsForStt({name: TaskName.Gather}, sttCredentials, language, {
|
||||
vendor,
|
||||
hints,
|
||||
enhancedModel: true,
|
||||
|
||||
@@ -102,6 +102,50 @@ const stickyVars = {
|
||||
]
|
||||
};
|
||||
|
||||
const optimalDeepramModels = {
|
||||
zh: ['base', 'base'],
|
||||
'zh-CN':['base', 'base'],
|
||||
'zh-TW': ['base', 'base'],
|
||||
da: ['enhanced', 'enhanced'],
|
||||
en: ['nova-2-conversationalai', 'nova-2'],
|
||||
'en-US': ['nova-2-conversationalai', 'nova-2'],
|
||||
'en-AU': ['nova-2-conversationalai', 'nova-2'],
|
||||
'en-GB': ['nova-2-conversationalai', 'nova-2'],
|
||||
'en-IN': ['nova-2-conversationalai', 'nova-2'],
|
||||
'en-NZ': ['nova-2-conversationalai', 'nova-2'],
|
||||
nl: ['nova-2-conversationalai', 'nova-2'],
|
||||
fr: ['nova-2-conversationalai', 'nova-2'],
|
||||
'fr-CA': ['nova-2-conversationalai', 'nova-2'],
|
||||
de: ['nova-2-conversationalai', 'nova-2'],
|
||||
hi: ['nova-2-conversationalai', 'nova-2'],
|
||||
'hi-Latn': ['nova-2-conversationalai', 'nova-2'],
|
||||
id: ['base', 'base'],
|
||||
it: ['enhanced', 'enhanced'],
|
||||
ja: ['enhanced', 'enhanced'],
|
||||
ko: ['enhanced', 'enhanced'],
|
||||
no: ['enhanced', 'enhanced'],
|
||||
pl: ['enhanced', 'enhanced'],
|
||||
pt: ['nova-2-conversationalai', 'nova-2'],
|
||||
'pt-BR': ['nova-2-conversationalai', 'nova-2'],
|
||||
'pt-PT': ['base', 'base'],
|
||||
ru: ['base', 'base'],
|
||||
es: ['nova-2-conversationalai', 'nova-2'],
|
||||
'es-419': ['nova-2-conversationalai', 'nova-2'],
|
||||
'es-LATAM': ['enhanced', 'enhanced'],
|
||||
sv: ['enhanced', 'enhanced'],
|
||||
ta: ['enhanced', 'enhanced'],
|
||||
taq: ['enhanced', 'enhanced'],
|
||||
tr: ['base', 'base'],
|
||||
uk: ['base', 'base']
|
||||
};
|
||||
|
||||
const selectDefaultDeepgramModel = (task, language) => {
|
||||
if (language in optimalDeepramModels) {
|
||||
const [gather, transcribe] = optimalDeepramModels[language];
|
||||
return task.name === TaskName.Gather ? gather : transcribe;
|
||||
}
|
||||
};
|
||||
|
||||
const consolidateTranscripts = (bufferedTranscripts, channel, language) => {
|
||||
if (bufferedTranscripts.length === 1) return bufferedTranscripts[0];
|
||||
let totalConfidence = 0;
|
||||
@@ -424,7 +468,7 @@ module.exports = (logger) => {
|
||||
}
|
||||
};
|
||||
|
||||
const setChannelVarsForStt = (task, sttCredentials, rOpts = {}) => {
|
||||
const setChannelVarsForStt = (task, sttCredentials, language, rOpts = {}) => {
|
||||
let opts = {};
|
||||
const {enable, voiceMs = 0, mode = -1} = rOpts.vad || {};
|
||||
const vad = {enable, voiceMs, mode};
|
||||
@@ -568,6 +612,9 @@ module.exports = (logger) => {
|
||||
}
|
||||
else if ('deepgram' === vendor) {
|
||||
const {deepgramOptions = {}} = rOpts;
|
||||
if (!deepgramOptions.model) {
|
||||
deepgramOptions.model = selectDefaultDeepgramModel(task, language);
|
||||
}
|
||||
opts = {
|
||||
...opts,
|
||||
...(sttCredentials.api_key) &&
|
||||
|
||||
Reference in New Issue
Block a user