@contentgrowth/llm-service 1.3.0 → 1.3.2

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/dist/index.d.cts CHANGED
@@ -61,6 +61,13 @@ declare class BaseLLMProvider {
61
61
  imageData: string;
62
62
  mimeType: string;
63
63
  }>;
64
+ /**
65
+ * Text-to-Speech synthesis
66
+ * @param {string} text - Text to synthesize
67
+ * @param {Object} options - TTS options (voice, model, etc.)
68
+ * @returns {Promise<Buffer>} Audio data as Buffer
69
+ */
70
+ textToSpeech(text: string, options?: any): Promise<Buffer>;
64
71
  /**
65
72
  * Start video generation (returns operation name for polling)
66
73
  * @param {string} prompt
@@ -344,6 +351,14 @@ declare class LLMService {
344
351
  * @param {Object} options - Generation options (aspectRatio, images, etc.)
345
352
  */
346
353
  imageGeneration(prompt: string, tenantId: string, systemPrompt: string, options?: any): Promise<any>;
354
+ /**
355
+ * Text-to-Speech synthesis
356
+ * @param {string} text - Text to synthesize
357
+ * @param {string} tenantId - Tenant identifier
358
+ * @param {Object} options - TTS options (voice, model, etc.)
359
+ * @returns {Promise<Buffer>} Audio data as Buffer
360
+ */
361
+ textToSpeech(text: string, tenantId: string, options?: any): Promise<Buffer>;
347
362
  /**
348
363
  * Start a Deep Research task
349
364
  * @param {string} prompt - Research prompt/query
@@ -631,6 +646,18 @@ declare class GoogleProvider extends BaseLLMProvider {
631
646
  error: any;
632
647
  }>;
633
648
  extractWithLLM(fileData: any, mimeType: any, prompt: any, schema?: any, options?: {}): Promise<any>;
649
+ /**
650
+ * Text-to-Speech synthesis using Gemini TTS models
651
+ * @param {string} text - Text to synthesize
652
+ * @param {Object} options - TTS options
653
+ * @param {string} options.voice - Voice name (default: 'Aoede')
654
+ * @param {string} options.model - Model to use (default: from config)
655
+ * @returns {Promise<Buffer>} Audio data as Buffer
656
+ */
657
+ textToSpeech(text: string, options?: {
658
+ voice: string;
659
+ model: string;
660
+ }): Promise<Buffer>;
634
661
  }
635
662
 
636
663
  /**
package/dist/index.d.ts CHANGED
@@ -61,6 +61,13 @@ declare class BaseLLMProvider {
61
61
  imageData: string;
62
62
  mimeType: string;
63
63
  }>;
64
+ /**
65
+ * Text-to-Speech synthesis
66
+ * @param {string} text - Text to synthesize
67
+ * @param {Object} options - TTS options (voice, model, etc.)
68
+ * @returns {Promise<Buffer>} Audio data as Buffer
69
+ */
70
+ textToSpeech(text: string, options?: any): Promise<Buffer>;
64
71
  /**
65
72
  * Start video generation (returns operation name for polling)
66
73
  * @param {string} prompt
@@ -344,6 +351,14 @@ declare class LLMService {
344
351
  * @param {Object} options - Generation options (aspectRatio, images, etc.)
345
352
  */
346
353
  imageGeneration(prompt: string, tenantId: string, systemPrompt: string, options?: any): Promise<any>;
354
+ /**
355
+ * Text-to-Speech synthesis
356
+ * @param {string} text - Text to synthesize
357
+ * @param {string} tenantId - Tenant identifier
358
+ * @param {Object} options - TTS options (voice, model, etc.)
359
+ * @returns {Promise<Buffer>} Audio data as Buffer
360
+ */
361
+ textToSpeech(text: string, tenantId: string, options?: any): Promise<Buffer>;
347
362
  /**
348
363
  * Start a Deep Research task
349
364
  * @param {string} prompt - Research prompt/query
@@ -631,6 +646,18 @@ declare class GoogleProvider extends BaseLLMProvider {
631
646
  error: any;
632
647
  }>;
633
648
  extractWithLLM(fileData: any, mimeType: any, prompt: any, schema?: any, options?: {}): Promise<any>;
649
+ /**
650
+ * Text-to-Speech synthesis using Gemini TTS models
651
+ * @param {string} text - Text to synthesize
652
+ * @param {Object} options - TTS options
653
+ * @param {string} options.voice - Voice name (default: 'Aoede')
654
+ * @param {string} options.model - Model to use (default: from config)
655
+ * @returns {Promise<Buffer>} Audio data as Buffer
656
+ */
657
+ textToSpeech(text: string, options?: {
658
+ voice: string;
659
+ model: string;
660
+ }): Promise<Buffer>;
634
661
  }
635
662
 
636
663
  /**
package/dist/index.js CHANGED
@@ -291,6 +291,15 @@ var BaseLLMProvider = class {
291
291
  async imageGeneration(prompt, systemPrompt, options = {}) {
292
292
  throw new Error("Image generation not supported by this provider");
293
293
  }
294
+ /**
295
+ * Text-to-Speech synthesis
296
+ * @param {string} text - Text to synthesize
297
+ * @param {Object} options - TTS options (voice, model, etc.)
298
+ * @returns {Promise<Buffer>} Audio data as Buffer
299
+ */
300
+ async textToSpeech(text, options = {}) {
301
+ throw new Error("Text-to-speech not supported by this provider");
302
+ }
294
303
  /**
295
304
  * Start video generation (returns operation name for polling)
296
305
  * @param {string} prompt
@@ -1171,6 +1180,52 @@ ${prompt}` : prompt;
1171
1180
  throw error;
1172
1181
  }
1173
1182
  }
1183
+ /**
1184
+ * Text-to-Speech synthesis using Gemini TTS models
1185
+ * @param {string} text - Text to synthesize
1186
+ * @param {Object} options - TTS options
1187
+ * @param {string} options.voice - Voice name (default: 'Aoede')
1188
+ * @param {string} options.model - Model to use (default: from config)
1189
+ * @returns {Promise<Buffer>} Audio data as Buffer
1190
+ */
1191
+ async textToSpeech(text, options = {}) {
1192
+ var _a, _b, _c, _d, _e;
1193
+ const voice = options.voice || "Aoede";
1194
+ const modelName = options.model || this.models.tts || "gemini-3.1-flash-tts-preview";
1195
+ const requestOptions = {
1196
+ model: modelName,
1197
+ contents: [{
1198
+ role: "user",
1199
+ parts: [{ text }]
1200
+ }],
1201
+ config: {
1202
+ responseModalities: ["AUDIO"],
1203
+ speechConfig: {
1204
+ voiceConfig: {
1205
+ prebuiltVoiceConfig: {
1206
+ voiceName: voice
1207
+ }
1208
+ }
1209
+ }
1210
+ }
1211
+ };
1212
+ try {
1213
+ const response = await this._generateContent(requestOptions);
1214
+ const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
1215
+ if (!candidate) {
1216
+ throw new LLMServiceException("No candidates returned from TTS model", 500);
1217
+ }
1218
+ const audioPart = (_c = (_b = candidate.content) == null ? void 0 : _b.parts) == null ? void 0 : _c.find((p) => p.inlineData || p.inline_data);
1219
+ const audioB64 = ((_d = audioPart == null ? void 0 : audioPart.inlineData) == null ? void 0 : _d.data) || ((_e = audioPart == null ? void 0 : audioPart.inline_data) == null ? void 0 : _e.data);
1220
+ if (!audioB64) {
1221
+ throw new LLMServiceException("No audio data returned from TTS model", 500);
1222
+ }
1223
+ return Buffer.from(audioB64, "base64");
1224
+ } catch (error) {
1225
+ console.error(`[${this.constructor.name}] textToSpeech failed (API Key: ${this._getMaskedApiKey()}):`, error);
1226
+ throw error;
1227
+ }
1228
+ }
1174
1229
  };
1175
1230
 
1176
1231
  // src/llm/providers/anthropic-provider.js
@@ -1641,6 +1696,17 @@ var LLMService = class {
1641
1696
  const provider = await this._getProvider(tenantId);
1642
1697
  return provider.imageGeneration(prompt, systemPrompt, options);
1643
1698
  }
1699
+ /**
1700
+ * Text-to-Speech synthesis
1701
+ * @param {string} text - Text to synthesize
1702
+ * @param {string} tenantId - Tenant identifier
1703
+ * @param {Object} options - TTS options (voice, model, etc.)
1704
+ * @returns {Promise<Buffer>} Audio data as Buffer
1705
+ */
1706
+ async textToSpeech(text, tenantId, options = {}) {
1707
+ const provider = await this._getProvider(tenantId);
1708
+ return provider.textToSpeech(text, options);
1709
+ }
1644
1710
  /**
1645
1711
  * Start a Deep Research task
1646
1712
  * @param {string} prompt - Research prompt/query