@jambonz/speech-utils 0.0.46 → 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.
@@ -141,12 +141,12 @@ async function synthAudio(client, logger, stats, { account_sid,
141
141
  let filePath;
142
142
  if (['nuance', 'nvidia'].includes(vendor) ||
143
143
  (
144
- process.env.JAMBONES_TTS_TRIM_SILENCE &&
144
+ (process.env.JAMBONES_TTS_TRIM_SILENCE || !process.env.JAMBONES_DISABLE_TTS_STREAMING) &&
145
145
  ['microsoft', 'azure'].includes(vendor)
146
146
  ) ||
147
147
  (
148
148
  !process.env.JAMBONES_DISABLE_TTS_STREAMING &&
149
- vendor === 'elevenlabs'
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jambonz/speech-utils",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "description": "TTS-related speech utilities for jambonz",
5
5
  "main": "index.js",
6
6
  "author": "Dave Horton",
package/test/synth.js CHANGED
@@ -595,6 +595,7 @@ test('Deepgram speech synth tests', async(t) => {
595
595
  },
596
596
  model: 'aura-asteria-en',
597
597
  text,
598
+ renderForCaching: true
598
599
  });
599
600
  t.ok(!opts.servedFromCache, `successfully synthesized deepgram audio to ${opts.filePath}`);
600
601