From 174438bb01ea8e77d002c64383c1bbc6897d24a0 Mon Sep 17 00:00:00 2001 From: rammohan-y <37395033+rammohan-y@users.noreply.github.com> Date: Tue, 3 Sep 2024 17:52:38 +0530 Subject: [PATCH] Feat/882: default model setting for en-IN language (#888) * feat/882: default model setting for en-IN language * feat/882: refactored if into || --- lib/utils/transcription-utils.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/utils/transcription-utils.js b/lib/utils/transcription-utils.js index 60965c11..2211bcf6 100644 --- a/lib/utils/transcription-utils.js +++ b/lib/utils/transcription-utils.js @@ -142,7 +142,6 @@ const optimalDeepramModels = { tr: ['nova-2', 'nova-2'], uk: ['nova-2', 'nova-2'] }; - const selectDefaultDeepgramModel = (task, language) => { if (language in optimalDeepramModels) { const [gather, transcribe] = optimalDeepramModels[language]; @@ -151,6 +150,24 @@ const selectDefaultDeepgramModel = (task, language) => { return 'base'; }; +const optimalGoogleModels = { + 'v1' : { + 'en-IN':['telephony', 'latest_long'] + }, + 'v2' : { + 'en-IN':['telephony', 'long'] + } +}; +const selectDefaultGoogleModel = (task, language, version) => { + const useV2 = version === 'v2'; + if (language in optimalGoogleModels[version]) { + const [gather, transcribe] = optimalGoogleModels[version][language]; + return task.name === TaskName.Gather ? gather : transcribe; + } + return task.name === TaskName.Gather ? + (useV2 ? 'telephony_short' : 'command_and_search') : + (useV2 ? 'long' : 'latest_long'); +}; const consolidateTranscripts = (bufferedTranscripts, channel, language, vendor) => { if (bufferedTranscripts.length === 1) return bufferedTranscripts[0]; let totalConfidence = 0; @@ -497,9 +514,9 @@ module.exports = (logger) => { if ('google' === vendor) { const useV2 = rOpts.googleOptions?.serviceVersion === 'v2'; - const model = task.name === TaskName.Gather ? - (useV2 ? 'telephony_short' : 'command_and_search') : - (useV2 ? 'long' : 'latest_long'); + const version = useV2 ? 'v2' : 'v1'; + let {model} = rOpts; + model = model || selectDefaultGoogleModel(task, language, version); opts = { ...opts, ...(sttCredentials && {GOOGLE_APPLICATION_CREDENTIALS: JSON.stringify(sttCredentials.credentials)}),