Merge pull request #63 from jambonz/feat/mod_deepgram_tts

Feat/mod deepgram tts
This commit is contained in:
Dave Horton
2024-04-04 15:52:10 -04:00
committed by GitHub
2 changed files with 20 additions and 3 deletions
+19 -3
View File
@@ -146,7 +146,7 @@ async function synthAudio(client, logger, stats, { account_sid,
) ||
(
!process.env.JAMBONES_DISABLE_TTS_STREAMING &&
vendor === 'elevenlabs'
['elevenlabs', 'deepgram'].includes(vendor)
)
) {
filePath = `${TMP_FOLDER}/${key.replace('tts:', `tts-${salt || ''}`)}.r8`;
@@ -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,
@@ -720,8 +722,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}`,
+1
View File
@@ -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}`);