@jambonz/speech-utils 0.0.41 → 0.0.42

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.
Files changed (2) hide show
  1. package/lib/synth-audio.js +22 -2
  2. package/package.json +1 -1
@@ -210,6 +210,10 @@ async function synthAudio(client, logger, stats, { account_sid,
210
210
  }
211
211
  break;
212
212
  case 'whisper':
213
+ audioBuffer = await synthWhisper(logger, {credentials, stats, voice, text, renderForCaching});
214
+ if (typeof audioBuffer === 'object' && audioBuffer.filePath) {
215
+ return audioBuffer;
216
+ }
213
217
  audioBuffer = await synthWhisper(logger, {credentials, stats, voice, text});
214
218
  break;
215
219
  case 'deepgram':
@@ -656,8 +660,24 @@ const synthElevenlabs = async(logger, {credentials, options, stats, language, vo
656
660
  }
657
661
  };
658
662
 
659
- const synthWhisper = async(logger, {credentials, stats, voice, text}) => {
660
- const {api_key, model_id, baseURL, timeout} = credentials;
663
+ const synthWhisper = async(logger, {credentials, stats, voice, text, renderForCaching}) => {
664
+ const {api_key, model_id, baseURL, timeout, speed} = credentials;
665
+ /* 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) {
667
+ let params = '';
668
+ params += `{api_key=${api_key}`;
669
+ params += `,model_id=${model_id}`;
670
+ params += `,voice=${voice}`;
671
+ params += ',write_cache_file=1';
672
+ if (speed) params += `,speed=${speed}`;
673
+ params += '}';
674
+
675
+ return {
676
+ filePath: `say:${params}${text.replace(/\n/g, ' ')}`,
677
+ servedFromCache: false,
678
+ rtt: 0
679
+ };
680
+ }
661
681
  try {
662
682
  const openai = new OpenAI.OpenAI({
663
683
  apiKey: api_key,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jambonz/speech-utils",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "description": "TTS-related speech utilities for jambonz",
5
5
  "main": "index.js",
6
6
  "author": "Dave Horton",