File size: 664 Bytes
73d4f3c 91b1985 c7fc3b6 73d4f3c 91b1985 73d4f3c 91b1985 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
from services.gemini_client import get_gemini_client
from google.genai import types
async def generate_tts(text: str) -> bytes:
client = get_gemini_client()
response = client.models.generate_content(
model="gemini-2.5-flash-preview-tts",
contents=text,
config=types.GenerateContentConfig(
response_modalities=["AUDIO"],
speech_config=types.SpeechConfig(
voice_config=types.VoiceConfig(
prebuilt_voice_config=types.PrebuiltVoiceConfig(voice_name="Kore")
)
),
),
)
return response.candidates[0].content.parts[0].inline_data.data
|