mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-07-04 19:31:49 +00:00
wip
This commit is contained in:
+9
-10
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user