This commit is contained in:
Quan HL
2024-07-29 20:53:55 +07:00
parent a595faa378
commit e0e4d47340
+9 -10
View File
@@ -151,6 +151,11 @@ async function synthAudio(client, createHash, retrieveHash, logger, stats, { acc
assert.ok(voice, 'synthAudio requires voice when verbio is used');
assert.ok(credentials.client_id, 'synthAudio requires client_id when verbio is used');
assert.ok(credentials.client_secret, 'synthAudio requires client_secret when verbio is used');
} else if ('deepgram' === vendor) {
if (!credentials.deepgram_tts_uri) {
assert.ok(credentials.api_key, 'synthAudio requires api_key when deepgram is used');
}
}
const key = makeSynthKey({
account_sid,
@@ -926,19 +931,13 @@ const synthDeepgram = async(logger, {credentials, stats, model, text, renderForC
};
}
try {
let host = 'https://api.deepgram.com';
let path = '/v1/speak';
if (deepgram_tts_uri) {
const arr = /^(https?:\/\/[^\/]+)(\/.*)?$/.exec(deepgram_tts_uri);
host = arr[1];
path = arr[2];
}
const post = bent(host, 'POST', 'buffer', {
'Authorization': `Token ${api_key}`,
const post = bent(deepgram_tts_uri || 'https://api.deepgram.com', 'POST', 'buffer', {
// on-premise deepgram does not require to have api_key
...(api_key && {'Authorization': `Token ${api_key}`}),
'Accept': 'audio/mpeg',
'Content-Type': 'application/json'
});
const mp3 = await post(`${path}?model=${model}`, {
const mp3 = await post(`/v1/speak?model=${model}`, {
text
});
return mp3;