mirror of
https://github.com/jambonz/speech-utils.git
synced 2026-01-25 02:08:26 +00:00
mod_deepgra_tts
This commit is contained in:
@@ -212,7 +212,9 @@ async function synthAudio(client, logger, stats, { account_sid,
|
||||
if (audioBuffer?.filePath) return audioBuffer;
|
||||
break;
|
||||
case 'deepgram':
|
||||
audioBuffer = await synthDeepgram(logger, {credentials, stats, model, text});
|
||||
audioBuffer = await synthDeepgram(logger, {credentials, stats, model, text,
|
||||
renderForCaching, disableTtsStreaming});
|
||||
if (audioBuffer?.filePath) return audioBuffer;
|
||||
break;
|
||||
case vendor.startsWith('custom') ? vendor : 'cant_match_value':
|
||||
({ audioBuffer, filePath } = await synthCustomVendor(logger,
|
||||
@@ -719,8 +721,22 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, renderForCa
|
||||
}
|
||||
};
|
||||
|
||||
const synthDeepgram = async(logger, {credentials, stats, model, text}) => {
|
||||
const synthDeepgram = async(logger, {credentials, stats, model, text, renderForCaching, disableTtsStreaming}) => {
|
||||
const {api_key} = credentials;
|
||||
if (!process.env.JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
||||
let params = '';
|
||||
params += `{api_key=${api_key}`;
|
||||
params += ',vendor=deepgram';
|
||||
params += `,voice=${model}`;
|
||||
params += ',write_cache_file=1';
|
||||
params += '}';
|
||||
|
||||
return {
|
||||
filePath: `say:${params}${text.replace(/\n/g, ' ')}`,
|
||||
servedFromCache: false,
|
||||
rtt: 0
|
||||
};
|
||||
}
|
||||
try {
|
||||
const post = bent('https://api.deepgram.com', 'POST', 'buffer', {
|
||||
'Authorization': `Token ${api_key}`,
|
||||
|
||||
@@ -595,6 +595,7 @@ test('Deepgram speech synth tests', async(t) => {
|
||||
},
|
||||
model: 'aura-asteria-en',
|
||||
text,
|
||||
renderForCaching: true
|
||||
});
|
||||
t.ok(!opts.servedFromCache, `successfully synthesized deepgram audio to ${opts.filePath}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user