This commit is contained in:
Hoan HL
2026-01-17 16:16:11 +07:00
parent 89007ba7cc
commit 10095de25d
2 changed files with 6 additions and 4 deletions

View File

@@ -421,8 +421,6 @@ const synthGoogle = async(logger, {
const isVoiceCloning = typeof voice === 'object' && voice.voice_cloning_key;
// HD voices have pattern like en-US-Chirp3-HD-Charon
const isHDVoice = typeof voice === 'string' && voice.includes('-HD-');
// Live API is used for HD voices and Gemini voices
const useLiveApi = isGemini || isHDVoice;
// Streaming support for Google TTS (Gemini, HD voices, and standard voices)
// Voice cloning does not support streaming
@@ -441,7 +439,8 @@ const synthGoogle = async(logger, {
params += `,voice=${voice}`;
params += `,language_code=${language || 'en-US'}`;
params += `,write_cache_file=${disableTtsCache ? 0 : 1}`;
params += `,use_live_api=${useLiveApi ? 1 : 0}`;
params += `,use_live_api=${isHDVoice ? 1 : 0}`;
params += `,use_gemini_tts=${isGemini ? 1 : 0}`;
if (model) params += `,model_name=${model}`;
if (gender) params += `,gender=${gender}`;
// comma is used to separate parameters in freeswitch tts module

View File

@@ -305,6 +305,7 @@ test('Google TTS streaming tests (!JAMBONES_DISABLE_TTS_STREAMING)', async(t) =>
t.ok(result.filePath.startsWith('say:'), 'Standard voice returns streaming say: path');
t.ok(result.filePath.includes('vendor=google'), 'Standard voice streaming path contains vendor=google');
t.ok(result.filePath.includes('use_live_api=0'), 'Standard voice uses use_live_api=0');
t.ok(result.filePath.includes('use_gemini_tts=0'), 'Standard voice uses use_gemini_tts=0');
t.ok(result.filePath.includes('voice=en-US-Wavenet-D'), 'Standard voice streaming path contains voice');
// Verify credentials are base64 encoded (no raw JSON braces that would break FreeSWitch parsing)
t.ok(result.filePath.includes('credentials='), 'Standard voice streaming path contains credentials');
@@ -327,6 +328,7 @@ test('Google TTS streaming tests (!JAMBONES_DISABLE_TTS_STREAMING)', async(t) =>
t.ok(result.filePath.startsWith('say:'), 'HD voice returns streaming say: path');
t.ok(result.filePath.includes('vendor=google'), 'HD voice streaming path contains vendor=google');
t.ok(result.filePath.includes('use_live_api=1'), 'HD voice uses use_live_api=1 (Live API)');
t.ok(result.filePath.includes('use_gemini_tts=0'), 'HD voice uses use_gemini_tts=0');
t.ok(result.filePath.includes('voice=en-US-Chirp3-HD-Charon'), 'HD voice streaming path contains voice');
// Test 3: Gemini TTS streaming (use_live_api=1)
@@ -347,7 +349,8 @@ test('Google TTS streaming tests (!JAMBONES_DISABLE_TTS_STREAMING)', async(t) =>
});
t.ok(result.filePath.startsWith('say:'), 'Gemini TTS returns streaming say: path');
t.ok(result.filePath.includes('vendor=google'), 'Gemini TTS streaming path contains vendor=google');
t.ok(result.filePath.includes('use_live_api=1'), 'Gemini TTS uses use_live_api=1 (Live API)');
t.ok(result.filePath.includes('use_live_api=0'), 'Gemini TTS uses use_live_api=0');
t.ok(result.filePath.includes('use_gemini_tts=1'), 'Gemini TTS uses use_gemini_tts=1');
t.ok(result.filePath.includes(`model_name=${geminiModel}`), 'Gemini TTS streaming path contains model_name');
t.ok(result.filePath.includes('prompt=Speak naturally.'), 'Gemini TTS streaming path contains prompt');