mirror of
https://github.com/jambonz/speech-utils.git
synced 2025-12-19 03:37:49 +00:00
deepgram tts support endpoint for on-premise
This commit is contained in:
@@ -909,13 +909,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,12 +926,19 @@ const synthDeepgram = async(logger, {credentials, stats, model, text, renderForC
|
||||
};
|
||||
}
|
||||
try {
|
||||
const post = bent('https://api.deepgram.com', 'POST', 'buffer', {
|
||||
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}`,
|
||||
'Accept': 'audio/mpeg',
|
||||
'Content-Type': 'application/json'
|
||||
});
|
||||
const mp3 = await post(`/v1/speak?model=${model}`, {
|
||||
const mp3 = await post(`${path}?model=${model}`, {
|
||||
text
|
||||
});
|
||||
return mp3;
|
||||
|
||||
Reference in New Issue
Block a user