@jambonz/speech-utils 0.0.47 → 0.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/synth-audio.js +19 -3
- package/package.json +1 -1
- package/test/synth.js +1 -0
package/lib/synth-audio.js
CHANGED
|
@@ -146,7 +146,7 @@ async function synthAudio(client, logger, stats, { account_sid,
|
|
|
146
146
|
) ||
|
|
147
147
|
(
|
|
148
148
|
!process.env.JAMBONES_DISABLE_TTS_STREAMING &&
|
|
149
|
-
|
|
149
|
+
['elevenlabs', 'deepgram'].includes(vendor)
|
|
150
150
|
)
|
|
151
151
|
) {
|
|
152
152
|
filePath = `${TMP_FOLDER}/${key.replace('tts:', `tts-${salt || ''}`)}.r8`;
|
|
@@ -212,7 +212,9 @@ async function synthAudio(client, logger, stats, { account_sid,
|
|
|
212
212
|
if (audioBuffer?.filePath) return audioBuffer;
|
|
213
213
|
break;
|
|
214
214
|
case 'deepgram':
|
|
215
|
-
audioBuffer = await synthDeepgram(logger, {credentials, stats, model, text
|
|
215
|
+
audioBuffer = await synthDeepgram(logger, {credentials, stats, model, text,
|
|
216
|
+
renderForCaching, disableTtsStreaming});
|
|
217
|
+
if (audioBuffer?.filePath) return audioBuffer;
|
|
216
218
|
break;
|
|
217
219
|
case vendor.startsWith('custom') ? vendor : 'cant_match_value':
|
|
218
220
|
({ audioBuffer, filePath } = await synthCustomVendor(logger,
|
|
@@ -720,8 +722,22 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, renderForCa
|
|
|
720
722
|
}
|
|
721
723
|
};
|
|
722
724
|
|
|
723
|
-
const synthDeepgram = async(logger, {credentials, stats, model, text}) => {
|
|
725
|
+
const synthDeepgram = async(logger, {credentials, stats, model, text, renderForCaching, disableTtsStreaming}) => {
|
|
724
726
|
const {api_key} = credentials;
|
|
727
|
+
if (!process.env.JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
|
|
728
|
+
let params = '';
|
|
729
|
+
params += `{api_key=${api_key}`;
|
|
730
|
+
params += ',vendor=deepgram';
|
|
731
|
+
params += `,voice=${model}`;
|
|
732
|
+
params += ',write_cache_file=1';
|
|
733
|
+
params += '}';
|
|
734
|
+
|
|
735
|
+
return {
|
|
736
|
+
filePath: `say:${params}${text.replace(/\n/g, ' ')}`,
|
|
737
|
+
servedFromCache: false,
|
|
738
|
+
rtt: 0
|
|
739
|
+
};
|
|
740
|
+
}
|
|
725
741
|
try {
|
|
726
742
|
const post = bent('https://api.deepgram.com', 'POST', 'buffer', {
|
|
727
743
|
'Authorization': `Token ${api_key}`,
|
package/package.json
CHANGED
package/test/synth.js
CHANGED