Skip to content

Commit

Permalink
support custom tts streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
xquanluu committed Jan 7, 2025
1 parent 23cd440 commit 3d5a514
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/routes/api/speech-credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ const encryptCredential = (obj) => {
user_id,
voice_engine,
engine_version,
options
options,
use_audio_resampling,
use_base64_encoding,
use_tls
} = obj;

switch (vendor) {
Expand Down Expand Up @@ -284,7 +287,8 @@ const encryptCredential = (obj) => {

default:
if (vendor.startsWith('custom:')) {
const customData = JSON.stringify({auth_token, custom_stt_url, custom_tts_url});
const customData = JSON.stringify({auth_token, custom_stt_url, custom_tts_url,
use_audio_resampling, use_base64_encoding, use_tls});
return encrypt(customData);
}
else assert(false, `invalid or missing vendor: ${vendor}`);
Expand Down Expand Up @@ -475,7 +479,10 @@ router.put('/:sid', async(req, res) => {
deepgram_stt_uri,
deepgram_stt_use_tls,
deepgram_tts_uri,
engine_version
engine_version,
use_audio_resampling,
use_base64_encoding,
use_tls
} = req.body;

const newCred = {
Expand Down Expand Up @@ -503,7 +510,10 @@ router.put('/:sid', async(req, res) => {
deepgram_stt_uri,
deepgram_stt_use_tls,
deepgram_tts_uri,
engine_version
engine_version,
use_audio_resampling,
use_base64_encoding,
use_tls
};
logger.info({o, newCred}, 'updating speech credential with this new credential');
obj.credential = encryptCredential(newCred);
Expand Down
3 changes: 3 additions & 0 deletions lib/utils/speech-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,9 @@ function decryptCredential(obj, credential, logger, isObscureKey = true) {
obj.auth_token = isObscureKey ? obscureKey(o.auth_token) : o.auth_token;
obj.custom_stt_url = o.custom_stt_url;
obj.custom_tts_url = o.custom_tts_url;
obj.use_audio_resampling = o.use_audio_resampling;
obj.use_base64_encoding = o.use_base64_encoding;
obj.use_tls = o.use_tls;
} else if ('assemblyai' === obj.vendor) {
const o = JSON.parse(decrypt(credential));
obj.api_key = isObscureKey ? obscureKey(o.api_key) : o.api_key;
Expand Down

0 comments on commit 3d5a514

Please sign in to comment.