@jambonz/speech-utils 0.0.42 → 0.0.43

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.
@@ -77,7 +77,7 @@ const trimTrailingSilence = (buffer) => {
77
77
  */
78
78
  async function synthAudio(client, logger, stats, { account_sid,
79
79
  vendor, language, voice, gender, text, engine, salt, model, credentials, deploymentId,
80
- disableTtsCache, renderForCaching, options
80
+ disableTtsCache, renderForCaching, disableTtsStreaming, options
81
81
  }) {
82
82
  let audioBuffer;
83
83
  let servedFromCache = false;
@@ -200,21 +200,14 @@ async function synthAudio(client, logger, stats, { account_sid,
200
200
  break;
201
201
  case 'elevenlabs':
202
202
  audioBuffer = await synthElevenlabs(logger, {
203
- credentials, options, stats, language, voice, text, renderForCaching, filePath
203
+ credentials, options, stats, language, voice, text, renderForCaching, disableTtsStreaming, filePath
204
204
  });
205
- if (typeof audioBuffer === 'object' && audioBuffer.filePath) {
206
- return audioBuffer;
207
- }
208
- else {
209
- audioBuffer = await synthElevenlabs(logger, {credentials, options, stats, language, voice, text, filePath});
210
- }
205
+ if (audioBuffer?.filePath) return audioBuffer;
211
206
  break;
212
207
  case 'whisper':
213
- audioBuffer = await synthWhisper(logger, {credentials, stats, voice, text, renderForCaching});
214
- if (typeof audioBuffer === 'object' && audioBuffer.filePath) {
215
- return audioBuffer;
216
- }
217
- audioBuffer = await synthWhisper(logger, {credentials, stats, voice, text});
208
+ audioBuffer = await synthWhisper(logger, {
209
+ credentials, stats, voice, text, renderForCaching, disableTtsStreaming});
210
+ if (audioBuffer?.filePath) return audioBuffer;
218
211
  break;
219
212
  case 'deepgram':
220
213
  audioBuffer = await synthDeepgram(logger, {credentials, stats, model, text});
@@ -611,12 +604,14 @@ const synthCustomVendor = async(logger, {credentials, stats, language, voice, te
611
604
  }
612
605
  };
613
606
 
614
- const synthElevenlabs = async(logger, {credentials, options, stats, language, voice, text, renderForCaching}) => {
607
+ const synthElevenlabs = async(logger, {
608
+ credentials, options, stats, voice, text, renderForCaching, disableTtsStreaming
609
+ }) => {
615
610
  const {api_key, model_id, options: credOpts} = credentials;
616
611
  const opts = !!options && Object.keys(options).length !== 0 ? options : JSON.parse(credOpts || '{}');
617
612
 
618
613
  /* default to using the streaming interface, unless disabled by env var OR we want just a cache file */
619
- if (!process.env.JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching) {
614
+ if (!process.env.JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
620
615
  let params = '';
621
616
  params += `{api_key=${api_key}`;
622
617
  params += `,model_id=${model_id}`;
@@ -660,10 +655,10 @@ const synthElevenlabs = async(logger, {credentials, options, stats, language, vo
660
655
  }
661
656
  };
662
657
 
663
- const synthWhisper = async(logger, {credentials, stats, voice, text, renderForCaching}) => {
658
+ const synthWhisper = async(logger, {credentials, stats, voice, text, renderForCaching, disableTtsStreaming}) => {
664
659
  const {api_key, model_id, baseURL, timeout, speed} = credentials;
665
660
  /* if the env is set to stream then bag out, unless we are specifically rendering to generate a cache file */
666
- if (!process.env.JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching) {
661
+ if (!process.env.JAMBONES_DISABLE_TTS_STREAMING && !renderForCaching && !disableTtsStreaming) {
667
662
  let params = '';
668
663
  params += `{api_key=${api_key}`;
669
664
  params += `,model_id=${model_id}`;
@@ -702,7 +697,7 @@ const synthWhisper = async(logger, {credentials, stats, voice, text, renderForCa
702
697
  const synthDeepgram = async(logger, {credentials, stats, model, text}) => {
703
698
  const {api_key} = credentials;
704
699
  try {
705
- const post = bent('https://api.beta.deepgram.com', 'POST', 'buffer', {
700
+ const post = bent('https://api.deepgram.com', 'POST', 'buffer', {
706
701
  'Authorization': `Token ${api_key}`,
707
702
  'Accept': 'audio/mpeg',
708
703
  'Content-Type': 'application/json'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jambonz/speech-utils",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "description": "TTS-related speech utilities for jambonz",
5
5
  "main": "index.js",
6
6
  "author": "Dave Horton",
package/test/synth.js CHANGED
@@ -537,7 +537,7 @@ test('Deepgram speech synth tests', async(t) => {
537
537
  credentials: {
538
538
  api_key: process.env.DEEPGRAM_API_KEY
539
539
  },
540
- model: 'alpha-asteria-en-v2',
540
+ model: 'aura-asteria-en',
541
541
  text,
542
542
  });
543
543
  t.ok(!opts.servedFromCache, `successfully synthesized deepgram audio to ${opts.filePath}`);