For “gemini-live-2.5-flash-preview” model - voice_name is not working. I tested it with “gemini-2.5-flash-native-audio-preview-09-2025”, it works well though.
geminiSession = await ai.live.connect({
model : “gemini-2.5-flash-native-audio-preview-09-2025”,
config: {
responseModalities: [Modality.AUDIO],
systemInstruction: {
parts: [{ text: `` }]
},
speechConfig: {
voiceConfig: {
prebuiltVoiceConfig: {
voiceName: “Autonoe” // Female voice
}
}
}
Hii StellaHoang,
Apologies for the delayed response.
Could you please provide the complete error message encountered while using the gemini-live-2.5-flash-preview model?
This will help us investigate the issue more effectively.
My apologies for not being clear, there was no error, it just if you set name for different voices for the non-native model, it wouldn’t work. The model would just randomly response with a different voice each time.
We didn’t observe it with the native model.
Hii,
We tested it using the gemini-2.5-flash-preview-tts model, and it’s working on our end. We recommend using gemini-2.5-flash-preview-tts for a better experience.
Code:
from google import genai
from google.genai import types
from google.colab import userdata
API_KEY = userdata.get(‘API_KEY’)
client = genai.Client(api_key=API_KEY)
import wave
def wave_file(filename, pcm, channels=1, rate=24000, sample_width=2):
with wave.open(filename, “wb”) as wf:
wf.setnchannels(channels)
wf.setsampwidth(sample_width)
wf.setframerate(rate)
wf.writeframes(pcm)
import waveresponse = client.models.generate_content(
model=“gemini-2.5-flash-preview-tts”,
contents=“Say cheerfully: Have a wonderful day!”,
config=types.GenerateContentConfig(
response_modalities=[“AUDIO”],
speech_config=types.SpeechConfig(
voice_config=types.VoiceConfig(
prebuilt_voice_config=types.PrebuiltVoiceConfig(
voice_name=‘Autonoe’,
)
)
),
)
)
data = response.candidates[0].content.parts[0].inline_data.data
file_name=‘output.wav’
wave_file(file_name, data)