How to Use Gemini 3.1 Flash TTS
-
Define your speakers: Add one entry per voice to the speakers list. Give each a speaker_id in "Speaker N" format, pick a voice_name, and set the accent, style, and pace. Optionally add an audio_profile describing the persona.
-
Write the dialogue: Fill dialogue_turns with ordered lines. Each turn's speaker_id must match a speaker you defined. You can embed tone tags inline such as [whispers], [shouting], or [determination].
-
Set the mood (optional): Use scene to describe the acoustic setting and sample_context to set the overall narration tone. Adjust temperature (0-2) for more or less varied delivery.
-
Submit and poll: POST the request, then poll /predictions/{request_id}/result until the status is completed to get the audio URL.
curl -X POST https://api.muapi.ai/api/v1/gemini-3-1-flash-tts \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"speakers": [
{"speaker_id": "Speaker 1", "voice_name": "Fenrir", "accent": "British (RP)", "style": "Deadpan", "pace": "Natural"},
{"speaker_id": "Speaker 2", "voice_name": "Puck", "accent": "American (Gen)", "style": "Empathetic", "pace": "Staccato"}
],
"dialogue_turns": [
{"speaker_id": "Speaker 1", "text": "[shouting] Halt, traveler!"},
{"speaker_id": "Speaker 2", "text": "[determination] I carry a message for the elder."}
],
"scene": "A dark, crumbling dungeon.",
"temperature": 1
}'