initial changes for deepgram on-prem (#636)

* initial changes for deepgram on-prem

* typo

* fixes for selecting deepgram model

* update some property names

* wip

* wip

* wip
This commit is contained in:
Dave Horton
2024-02-07 14:21:05 -05:00
committed by GitHub
parent 75566bb268
commit 9f9a9ec598
3 changed files with 16 additions and 5 deletions

View File

@@ -751,7 +751,9 @@ class CallSession extends Emitter {
else if ('deepgram' === vendor) { else if ('deepgram' === vendor) {
return { return {
speech_credential_sid: credential.speech_credential_sid, speech_credential_sid: credential.speech_credential_sid,
api_key: credential.api_key api_key: credential.api_key,
deepgram_stt_uri: credential.deepgram_stt_uri,
deepgram_stt_use_tls: credential.deepgram_stt_use_tls
}; };
} }
else if ('soniox' === vendor) { else if ('soniox' === vendor) {

View File

@@ -75,6 +75,8 @@ const speechMapper = (cred) => {
else if ('deepgram' === obj.vendor) { else if ('deepgram' === obj.vendor) {
const o = JSON.parse(decrypt(credential)); const o = JSON.parse(decrypt(credential));
obj.api_key = o.api_key; obj.api_key = o.api_key;
obj.deepgram_stt_uri = o.deepgram_stt_uri;
obj.deepgram_stt_use_tls = o.deepgram_stt_use_tls;
} }
else if ('soniox' === obj.vendor) { else if ('soniox' === obj.vendor) {
const o = JSON.parse(decrypt(credential)); const o = JSON.parse(decrypt(credential));

View File

@@ -144,6 +144,7 @@ const selectDefaultDeepgramModel = (task, language) => {
const [gather, transcribe] = optimalDeepramModels[language]; const [gather, transcribe] = optimalDeepramModels[language];
return task.name === TaskName.Gather ? gather : transcribe; return task.name === TaskName.Gather ? gather : transcribe;
} }
return 'base';
}; };
const consolidateTranscripts = (bufferedTranscripts, channel, language) => { const consolidateTranscripts = (bufferedTranscripts, channel, language) => {
@@ -614,18 +615,24 @@ module.exports = (logger) => {
}; };
} }
else if ('deepgram' === vendor) { else if ('deepgram' === vendor) {
let {model} = rOpts;
const {deepgramOptions = {}} = rOpts; const {deepgramOptions = {}} = rOpts;
if (!deepgramOptions.model) { const deepgramUri = deepgramOptions.deepgramSttUri || sttCredentials.deepgram_stt_uri;
deepgramOptions.model = selectDefaultDeepgramModel(task, language); const useTls = deepgramOptions.deepgramSttUseTls || sttCredentials.deepgram_stt_use_tls;
/* default to a sensible model if not supplied */
if (!model) {
model = selectDefaultDeepgramModel(task, language);
} }
opts = { opts = {
...opts, ...opts,
DEEPGRAM_SPEECH_MODEL: model,
...(deepgramUri && {DEEPGRAM_URI: deepgramUri}),
...(deepgramUri && useTls && {DEEPGRAM_USE_TLS: 1}),
...(sttCredentials.api_key) && ...(sttCredentials.api_key) &&
{DEEPGRAM_API_KEY: sttCredentials.api_key}, {DEEPGRAM_API_KEY: sttCredentials.api_key},
...(deepgramOptions.tier) && ...(deepgramOptions.tier) &&
{DEEPGRAM_SPEECH_TIER: deepgramOptions.tier}, {DEEPGRAM_SPEECH_TIER: deepgramOptions.tier},
...(deepgramOptions.model) &&
{DEEPGRAM_SPEECH_MODEL: deepgramOptions.model},
...(deepgramOptions.punctuate) && ...(deepgramOptions.punctuate) &&
{DEEPGRAM_SPEECH_ENABLE_AUTOMATIC_PUNCTUATION: 1}, {DEEPGRAM_SPEECH_ENABLE_AUTOMATIC_PUNCTUATION: 1},
...(deepgramOptions.smartFormatting) && ...(deepgramOptions.smartFormatting) &&