@contentgrowth/llm-service 1.3.0 → 1.3.1

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
@@ -631,6 +631,18 @@ declare class GoogleProvider extends BaseLLMProvider {
631
631
  error: any;
632
632
  }>;
633
633
  extractWithLLM(fileData: any, mimeType: any, prompt: any, schema?: any, options?: {}): Promise<any>;
634
+ /**
635
+ * Text-to-Speech synthesis using Gemini TTS models
636
+ * @param {string} text - Text to synthesize
637
+ * @param {Object} options - TTS options
638
+ * @param {string} options.voice - Voice name (default: 'Aoede')
639
+ * @param {string} options.model - Model to use (default: from config)
640
+ * @returns {Promise<Buffer>} Audio data as Buffer
641
+ */
642
+ textToSpeech(text: string, options?: {
643
+ voice: string;
644
+ model: string;
645
+ }): Promise<Buffer>;
634
646
  }
635
647
 
636
648
  /**
package/dist/index.d.ts CHANGED
@@ -631,6 +631,18 @@ declare class GoogleProvider extends BaseLLMProvider {
631
631
  error: any;
632
632
  }>;
633
633
  extractWithLLM(fileData: any, mimeType: any, prompt: any, schema?: any, options?: {}): Promise<any>;
634
+ /**
635
+ * Text-to-Speech synthesis using Gemini TTS models
636
+ * @param {string} text - Text to synthesize
637
+ * @param {Object} options - TTS options
638
+ * @param {string} options.voice - Voice name (default: 'Aoede')
639
+ * @param {string} options.model - Model to use (default: from config)
640
+ * @returns {Promise<Buffer>} Audio data as Buffer
641
+ */
642
+ textToSpeech(text: string, options?: {
643
+ voice: string;
644
+ model: string;
645
+ }): Promise<Buffer>;
634
646
  }
635
647
 
636
648
  /**
package/dist/index.js CHANGED
@@ -1171,6 +1171,52 @@ ${prompt}` : prompt;
1171
1171
  throw error;
1172
1172
  }
1173
1173
  }
1174
+ /**
1175
+ * Text-to-Speech synthesis using Gemini TTS models
1176
+ * @param {string} text - Text to synthesize
1177
+ * @param {Object} options - TTS options
1178
+ * @param {string} options.voice - Voice name (default: 'Aoede')
1179
+ * @param {string} options.model - Model to use (default: from config)
1180
+ * @returns {Promise<Buffer>} Audio data as Buffer
1181
+ */
1182
+ async textToSpeech(text, options = {}) {
1183
+ var _a, _b, _c, _d, _e;
1184
+ const voice = options.voice || "Aoede";
1185
+ const modelName = options.model || this.models.tts || "gemini-3.1-flash-tts-preview";
1186
+ const requestOptions = {
1187
+ model: modelName,
1188
+ contents: [{
1189
+ role: "user",
1190
+ parts: [{ text }]
1191
+ }],
1192
+ config: {
1193
+ responseModalities: ["AUDIO"],
1194
+ speechConfig: {
1195
+ voiceConfig: {
1196
+ prebuiltVoiceConfig: {
1197
+ voiceName: voice
1198
+ }
1199
+ }
1200
+ }
1201
+ }
1202
+ };
1203
+ try {
1204
+ const response = await this._generateContent(requestOptions);
1205
+ const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
1206
+ if (!candidate) {
1207
+ throw new LLMServiceException("No candidates returned from TTS model", 500);
1208
+ }
1209
+ const audioPart = (_c = (_b = candidate.content) == null ? void 0 : _b.parts) == null ? void 0 : _c.find((p) => p.inlineData || p.inline_data);
1210
+ 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);
1211
+ if (!audioB64) {
1212
+ throw new LLMServiceException("No audio data returned from TTS model", 500);
1213
+ }
1214
+ return Buffer.from(audioB64, "base64");
1215
+ } catch (error) {
1216
+ console.error(`[${this.constructor.name}] textToSpeech failed (API Key: ${this._getMaskedApiKey()}):`, error);
1217
+ throw error;
1218
+ }
1219
+ }
1174
1220
  };
1175
1221
 
1176
1222
  // src/llm/providers/anthropic-provider.js