support deepgram tts onprem (#292)

* support deepgram tts onprem

* wip

* wip

* deepgram disable speech test if api_key is missng
This commit is contained in:
Hoan Luu Huu authored and GitHub committed 2024-02-12 09:27:13 -05:00
1 parent 256ca440a0
commit 40e8d08727
3 files changed
+70 -5

No files matched your search

+14 -5
View File
@@ -116,6 +116,8 @@ const encryptCredential = (obj) => {
secret,
nuance_tts_uri,
nuance_stt_uri,
deepgram_stt_uri,
deepgram_stt_use_tls,
use_custom_tts,
custom_tts_endpoint,
custom_tts_endpoint_url,
@@ -186,8 +188,11 @@ const encryptCredential = (obj) => {
return encrypt(nuanceData);
case 'deepgram':
assert(api_key, 'invalid deepgram speech credential: api_key is required');
const deepgramData = JSON.stringify({api_key});
// API key is optional if onprem
if (!deepgram_stt_uri) {
assert(api_key, 'invalid deepgram speech credential: api_key is required');
}
const deepgramData = JSON.stringify({api_key, deepgram_stt_uri, deepgram_stt_use_tls});
return encrypt(deepgramData);
case 'ibm':
@@ -415,7 +420,9 @@ router.put('/:sid', async(req, res) => {
cobalt_server_uri,
model_id,
options,
use_streaming
use_streaming,
deepgram_stt_uri,
deepgram_stt_use_tls,
} = req.body;
const newCred = {
@@ -439,7 +446,9 @@ router.put('/:sid', async(req, res) => {
cobalt_server_uri,
model_id,
options,
use_streaming
use_streaming,
deepgram_stt_uri,
deepgram_stt_use_tls,
};
logger.info({o, newCred}, 'updating speech credential with this new credential');
obj.credential = encryptCredential(newCred);
@@ -650,7 +659,7 @@ router.get('/:sid/test', async(req, res) => {
SpeechCredential.ttsTestResult(sid, false);
}
}
if (cred.use_for_stt) {
if (cred.use_for_stt && api_key) {
try {
await testDeepgramStt(logger, {api_key});
results.stt.status = 'ok';