diff --git a/lib/session/call-session.js b/lib/session/call-session.js index c389124a..a14a10df 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -1139,6 +1139,7 @@ class CallSession extends Emitter { return { api_key: credential.api_key, model_id: credential.model_id, + stt_model_id: credential.stt_model_id, api_uri: credential.api_uri, options: credential.options }; diff --git a/lib/utils/db-utils.js b/lib/utils/db-utils.js index 8903ed3b..a602ff58 100644 --- a/lib/utils/db-utils.js +++ b/lib/utils/db-utils.js @@ -106,6 +106,7 @@ const speechMapper = (cred) => { const o = JSON.parse(decrypt(credential)); obj.api_key = o.api_key; obj.model_id = o.model_id; + obj.stt_model_id = o.stt_model_id; obj.api_uri = o.api_uri; obj.options = o.options; } diff --git a/lib/utils/transcription-utils.js b/lib/utils/transcription-utils.js index beb50380..93eadfe3 100644 --- a/lib/utils/transcription-utils.js +++ b/lib/utils/transcription-utils.js @@ -545,6 +545,21 @@ const normalizeVerbio = (evt, channel, language) => { }; }; +const normalizeElevenlabs = (evt, channel, language) => { + const copy = JSON.parse(JSON.stringify(evt)); + console.log(copy); + return { + language_code: language, + channel_tag: channel, + is_final: evt.is_final, + alternatives: evt.alternatives, + vendor: { + name: 'elevenlabs', + evt: copy + } + }; +}; + const normalizeMicrosoft = (evt, channel, language, punctuation = true) => { const copy = JSON.parse(JSON.stringify(evt)); const nbest = evt.NBest; @@ -770,6 +785,8 @@ module.exports = (logger) => { return normalizeGladia(evt, channel, language, shortUtterance); case 'deepgramflux': return normalizeDeepgramFlux(evt, channel, language, shortUtterance); + case 'elevenlabs': + return normalizeElevenlabs(evt, channel, language); case 'microsoft': return normalizeMicrosoft(evt, channel, language, punctuation); case 'google': @@ -1085,6 +1102,24 @@ module.exports = (logger) => { ...(keyterms && keyterms.length > 0 && {DEEPGRAMFLUX_SPEECH_KEYTERMS: keyterms.join(',')}), }; } + else if ('elevenlabs' === vendor) { + const {api_key, stt_model_id} = sttCredentials; + const {includeTimestamps, commitStrategy, vadSilenceThresholdSecs, vadThreshold, + minSpeechDurationMs, minSilenceDurationMs, enableLogging} = rOpts.elevenlabsOptions || {}; + + opts = { + ...opts, + ELEVENLABS_API_KEY: api_key, + ELEVENLABS_MODEL_ID: stt_model_id, + ELEVENLABS_INCLUDE_TIMESTAMPS: includeTimestamps === true ? true : false, + ...(commitStrategy && {ELEVENLABS_COMMIT_STRATEGY: commitStrategy}), + ...(vadSilenceThresholdSecs && {ELEVENLABS_VAD_SILENCE_THRESHOLD_SECS: vadSilenceThresholdSecs}), + ...(vadThreshold && {ELEVENLABS_VAD_THRESHOLD: vadThreshold}), + ...(minSpeechDurationMs && {ELEVENLABS_MIN_SPEECH_DURATION_MS: minSpeechDurationMs}), + ...(minSilenceDurationMs && {ELEVENLABS_MIN_SILENCE_DURATION_MS: minSilenceDurationMs}), + ...(enableLogging && {ELEVENLABS_ENABLE_LOGGING: enableLogging ? 1 : 0}), + }; + } else if ('gladia' === vendor) { const {host, path} = sttCredentials; opts = {