mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-07-17 01:31:48 +00:00
Merge pull request #82 from jambonz/feat/deepgram_tts_endpoint
deepgram tts support endpoint for on-premise
This commit is contained in:
+10
-3
@@ -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,
|
||||
@@ -909,13 +914,14 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, renderForCa
|
||||
};
|
||||
|
||||
const synthDeepgram = async(logger, {credentials, stats, model, text, renderForCaching, disableTtsStreaming}) => {
|
||||
const {api_key} = credentials;
|
||||
const {api_key, deepgram_tts_uri} = credentials;
|
||||
if (!JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
||||
let params = '';
|
||||
params += `{api_key=${api_key}`;
|
||||
params += ',vendor=deepgram';
|
||||
params += `,voice=${model}`;
|
||||
params += ',write_cache_file=1';
|
||||
if (deepgram_tts_uri) params += `,endpoint=${deepgram_tts_uri}`;
|
||||
params += '}';
|
||||
|
||||
return {
|
||||
@@ -925,8 +931,9 @@ const synthDeepgram = async(logger, {credentials, stats, model, text, renderForC
|
||||
};
|
||||
}
|
||||
try {
|
||||
const post = bent('https://api.deepgram.com', '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'
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user