From 256ca440a09ae8803a47cdf1c5af86bd679b4d90 Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:18:49 +0700 Subject: [PATCH] add use_streaming flag for elevenlabs and whisper (#290) * add use_streaming flag for elevenlabs (not for whisper yet) --------- Co-authored-by: Dave Horton --- lib/routes/api/speech-credentials.js | 11 +++++++---- lib/utils/speech-utils.js | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/routes/api/speech-credentials.js b/lib/routes/api/speech-credentials.js index 54e071f2..43ac9d02 100644 --- a/lib/routes/api/speech-credentials.js +++ b/lib/routes/api/speech-credentials.js @@ -133,7 +133,8 @@ const encryptCredential = (obj) => { auth_token = '', cobalt_server_uri, model_id, - options + options, + use_streaming } = obj; switch (vendor) { @@ -211,7 +212,7 @@ const encryptCredential = (obj) => { case 'elevenlabs': assert(api_key, 'invalid elevenLabs speech credential: api_key is required'); assert(model_id, 'invalid elevenLabs speech credential: model_id is required'); - const elevenlabsData = JSON.stringify({api_key, model_id, options}); + const elevenlabsData = JSON.stringify({api_key, model_id, options, use_streaming}); return encrypt(elevenlabsData); case 'assemblyai': @@ -413,7 +414,8 @@ router.put('/:sid', async(req, res) => { custom_tts_url, cobalt_server_uri, model_id, - options + options, + use_streaming } = req.body; const newCred = { @@ -436,7 +438,8 @@ router.put('/:sid', async(req, res) => { custom_tts_url, cobalt_server_uri, model_id, - options + options, + use_streaming }; logger.info({o, newCred}, 'updating speech credential with this new credential'); obj.credential = encryptCredential(newCred); diff --git a/lib/utils/speech-utils.js b/lib/utils/speech-utils.js index 79b5c366..026c869c 100644 --- a/lib/utils/speech-utils.js +++ b/lib/utils/speech-utils.js @@ -428,6 +428,7 @@ function decryptCredential(obj, credential, logger, isObscureKey = true) { obj.api_key = isObscureKey ? obscureKey(o.api_key) : o.api_key; obj.model_id = o.model_id; obj.options = o.options; + obj.use_streaming = o.use_streaming; } else if (obj.vendor.startsWith('custom:')) { const o = JSON.parse(decrypt(credential)); obj.auth_token = isObscureKey ? obscureKey(o.auth_token) : o.auth_token;