# Gemini 3.8 Flash TTS > Generate expressive multi-speaker speech with Gemini 3.8 Flash TTS. Studio-grade voice fidelity and long-form stability. Try free, pay per use. ## 概览 - **端点**: `POST https://api.muapi.ai/api/v1/gemini-3-8-flash-tts` - **模型 ID**: `gemini-3-8-flash-tts` - **类别**: AI 音频 - **变体**: 3.8 Flash - **系列**: gemini-tts - **费用**: 每次调用 0.015 credits(部分模型会根据参数动态计算费用) ## API 使用 MuApi 使用**提交后轮询**模式:提交任务,获取 `request_id`,然后轮询预测端点,直到 `status` 为 `completed`。也可以在提交请求中传入 `?webhook=YOUR_URL`,任务完成后接收 POST 回调(无需轮询)。 **身份验证**:在 `x-api-key` 请求头中发送 MuApi 密钥。可在 https://muapi.ai/access-keys 获取。 ### 1. 提交任务 ```http POST https://api.muapi.ai/api/v1/gemini-3-8-flash-tts Content-Type: application/json x-api-key: YOUR_API_KEY ``` **最小请求(仅必填参数):** ```json { "speakers": [ { "speaker_id": "Speaker 1", "voice_name": "Fenrir", "audio_profile": "A stern and weary gatekeeper", "accent": "British (RP)", "style": "Deadpan", "pace": "Natural" }, { "speaker_id": "Speaker 2", "voice_name": "Puck", "audio_profile": "A determined and courageous traveler seeking answers.", "accent": "American (Gen)", "style": "Empathetic", "pace": "Staccato" } ], "dialogue_turns": [ { "speaker_id": "Speaker 1", "text": "[shouting] Halt, traveler! The northern pass is sealed by order of the council." }, { "speaker_id": "Speaker 2", "text": "[determination] I carry a message for the elder. Step aside, or I will force my way through." }, { "speaker_id": "Speaker 1", "text": "[caution] No one passes. [pensive] The elder is... he's no longer receiving visitors." }, { "speaker_id": "Speaker 2", "text": "It's too late. [whispers] The shadow... it reached him first. [urgency] You need to leave. [shouting] Now." } ] } ``` **完整示例(全部参数):** ```json { "speakers": [ { "speaker_id": "Speaker 1", "voice_name": "Fenrir", "audio_profile": "A stern and weary gatekeeper", "accent": "British (RP)", "style": "Deadpan", "pace": "Natural" }, { "speaker_id": "Speaker 2", "voice_name": "Puck", "audio_profile": "A determined and courageous traveler seeking answers.", "accent": "American (Gen)", "style": "Empathetic", "pace": "Staccato" } ], "dialogue_turns": [ { "speaker_id": "Speaker 1", "text": "[shouting] Halt, traveler! The northern pass is sealed by order of the council." }, { "speaker_id": "Speaker 2", "text": "[determination] I carry a message for the elder. Step aside, or I will force my way through." }, { "speaker_id": "Speaker 1", "text": "[caution] No one passes. [pensive] The elder is... he's no longer receiving visitors." }, { "speaker_id": "Speaker 2", "text": "It's too late. [whispers] The shadow... it reached him first. [urgency] You need to leave. [shouting] Now." } ], "scene": "", "sample_context": "", "temperature": 1 } ``` **响应:** ```json { "request_id": "abc123", "status": "processing" } ``` ### 2. 轮询结果 ```http GET https://api.muapi.ai/api/v1/predictions/{request_id}/result x-api-key: YOUR_API_KEY ``` 可能的 `status` 值:`queued`、`pending`、`processing`、`completed`、`failed`、`cancelled`。每 2–5 秒轮询一次,直到进入终止状态。状态为 `completed` 时,结果 URL 位于 `outputs` 数组中。 **`completed` 状态的响应示例:** ```json { "id": "abc123", "status": "completed", "outputs": [ "https://cdn.muapi.ai/.../output.png" ], "urls": { "get": "https://api.muapi.ai/api/v1/predictions/abc123/result" }, "created_at": "2026-05-08T12:34:56Z", "has_nsfw_contents": [] } ``` ### cURL ```bash 1. 提交 REQUEST_ID=$(curl -s -X POST https://api.muapi.ai/api/v1/gemini-3-8-flash-tts \ -H "x-api-key: $MUAPI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"speakers":[{"speaker_id":"Speaker 1","voice_name":"Fenrir","audio_profile":"A stern and weary gatekeeper","accent":"British (RP)","style":"Deadpan","pace":"Natural"},{"speaker_id":"Speaker 2","voice_name":"Puck","audio_profile":"A determined and courageous traveler seeking answers.","accent":"American (Gen)","style":"Empathetic","pace":"Staccato"}],"dialogue_turns":[{"speaker_id":"Speaker 1","text":"[shouting] Halt, traveler! The northern pass is sealed by order of the council."},{"speaker_id":"Speaker 2","text":"[determination] I carry a message for the elder. Step aside, or I will force my way through."},{"speaker_id":"Speaker 1","text":"[caution] No one passes. [pensive] The elder is... he's no longer receiving visitors."},{"speaker_id":"Speaker 2","text":"It's too late. [whispers] The shadow... it reached him first. [urgency] You need to leave. [shouting] Now."}]}' | jq -r .request_id) 2. 轮询直到完成 while :; do RESP=$(curl -s https://api.muapi.ai/api/v1/predictions/$REQUEST_ID/result -H "x-api-key: $MUAPI_API_KEY") STATUS=$(echo "$RESP" | jq -r .status) [ "$STATUS" = "completed" ] && echo "$RESP" | jq .outputs && break [ "$STATUS" = "failed" ] && echo "$RESP" && exit 1 sleep 3 done ``` ### Python ```python import os, time, requests API = "https://api.muapi.ai/api/v1" headers = {"x-api-key": os.environ["MUAPI_API_KEY"]} r = requests.post(f"{API}/gemini-3-8-flash-tts", headers=headers, json={"speakers":[{"speaker_id":"Speaker 1","voice_name":"Fenrir","audio_profile":"A stern and weary gatekeeper","accent":"British (RP)","style":"Deadpan","pace":"Natural"},{"speaker_id":"Speaker 2","voice_name":"Puck","audio_profile":"A determined and courageous traveler seeking answers.","accent":"American (Gen)","style":"Empathetic","pace":"Staccato"}],"dialogue_turns":[{"speaker_id":"Speaker 1","text":"[shouting] Halt, traveler! The northern pass is sealed by order of the council."},{"speaker_id":"Speaker 2","text":"[determination] I carry a message for the elder. Step aside, or I will force my way through."},{"speaker_id":"Speaker 1","text":"[caution] No one passes. [pensive] The elder is... he's no longer receiving visitors."},{"speaker_id":"Speaker 2","text":"It's too late. [whispers] The shadow... it reached him first. [urgency] You need to leave. [shouting] Now."}]}) request_id = r.json()["request_id"] while True: res = requests.get(f"{API}/predictions/{request_id}/result", headers=headers).json() if res["status"] == "completed": print(res["outputs"]); break if res["status"] == "failed": raise RuntimeError(res.get("error")); time.sleep(3) ``` ## 输入结构 API 接受以下输入参数: - **`speakers`** (`array`, _必填_): 说话人声音配置列表。每一轮对话通过 ID 引用一个说话人。 - **`speakers[].speaker_id`** (`string`, _必填_): 说话人标识符。必须使用 "Speaker N" 格式(例如 "Speaker 1")。 - **`speakers[].voice_name`** (`string`, _必填_): 预置 Gemini 声音名称。 - 选项: `"Achernar"`, `"Achird"`, `"Algenib"`, `"Algieba"`, `"Alnilam"`, `"Aoede"`, `"Autonoe"`, `"Callirrhoe"`, `"Charon"`, `"Despina"`, `"Enceladus"`, `"Erinome"`, `"Fenrir"`, `"Gacrux"`, `"Iapetus"`, `"Kore"`, `"Laomedeia"`, `"Leda"`, `"Orus"`, `"Puck"`, `"Pulcherrima"`, `"Rasalgethi"`, `"Sadachbia"`, `"Sadaltager"`, `"Schedar"`, `"Sulafat"`, `"Umbriel"`, `"Vindemiatrix"`, `"Zephyr"`, `"Zubenelgenubi"` - **`speakers[].audio_profile`** (`string`, _可选_): 可选的 natural-language description of the persona, e.g. "A warm and soothing narrator". - **`speakers[].accent`** (`string`, _必填_): 说话口音。 - 默认值: `"Neutral"` - 选项: `"Neutral"`, `"American (Gen)"`, `"American (Valley)"`, `"American (South)"`, `"British (RP)"`, `"British (Brixton)"`, `"Transatlantic"`, `"Australian"` - **`speakers[].style`** (`string`, _必填_): 情感表达风格。 - 默认值: `"Empathetic"` - 选项: `"Vocal Smile"`, `"Newscaster"`, `"Whisper"`, `"Empathetic"`, `"Promo/Hype"`, `"Deadpan"` - **`speakers[].pace`** (`string`, _必填_): 说话速度。 - 默认值: `"Natural"` - 选项: `"Natural"`, `"Rapid Fire"`, `"The Drift"`, `"Staccato"` - **`dialogue_turns`** (`array`, _必填_): 按顺序排列的对话行列表。每一轮的 speaker_id 必须匹配上面定义的说话人。文本可以包含 [shouting] 或 [whispers] 等语气标签。 - **`dialogue_turns[].speaker_id`** (`string`, _必填_): 朗读此行的说话人 ID(例如 "Speaker 1")。 - **`dialogue_turns[].text`** (`string`, _必填_): 要朗读的台词。支持内嵌语气标签。最多 10000 个字符。 - **`scene`** (`string`, _可选_): 可选的 scene description that sets the acoustic setting, e.g. "A quiet, warm room with a fireplace crackling softly." - 默认值: `""` - **`sample_context`** (`string`, _可选_): 可选的 overall tone/style, e.g. "Audiobook style narration. Tone is gentle and inviting." - 默认值: `""` - **`temperature`** (`number`, _可选_): 采样温度(0-2)。数值越高,表达方式越丰富。 - 默认值: `1` - 范围: `0` to `2` ## 输出结构 轮询端点会返回以下字段: - **`id`** (`string`): 请求 ID。 - **`status`** (`string`): 取值之一:`queued`、`pending`、`processing`、`completed`、`failed`、`cancelled`。 - **`outputs`** (`array`): 生成的图像、视频或音频 URL。`status` 为 `completed` 前为空。 - **`urls.get`** (`string`): 用于重新获取此预测结果的自身链接。 - **`error`** (`string` | `null`): `status` 为 `failed` 时的错误消息。 - **`created_at`** (`string`): 创建请求时的 ISO-8601 时间戳。 - **`has_nsfw_contents`** (`array of boolean`): 每个输出对应的 NSFW 检测标记。 ## Webhook(可选) 在提交 URL 后附加 `?webhook=https://your-server/path`。任务进入终止状态后,MuApi 会将与轮询响应相同结构的 POST 请求发送到你的 URL,无需轮询。 ## Agent 集成 MuApi 提供 MCP 服务器和 CLI,让 Agent(Claude Code、Cursor 或自定义 Agent)无需编写 HTTP 代码即可调用此端点: ```bash # 安装 CLI npm install -g muapi-cli # 完成一次身份验证 muapi auth login # 将所有 MuApi 模型作为 MCP 工具提供给 Agent muapi mcp serve ``` MCP 服务器为每个模型提供封装提交与轮询的工具,包括 `gemini-3-8-flash-tts`。使用 `muapi --help` 查看按类别划分的快捷命令(`muapi image generate`、`muapi video from-image` 等)。 ## 相关模型 - [3.1 Flash](https://muapi.ai/zh/playground/gemini-3-1-flash-tts) - [2.5 Pro](https://muapi.ai/zh/playground/gemini-2-5-pro-tts) - [3.8 Flash Lite](https://muapi.ai/zh/playground/gemini-3-8-flash-lite-tts) - [3.8 Flash](https://muapi.ai/zh/playground/gemini-3-8-flash-tts) ## 资源 - [Playground 页面](https://muapi.ai/zh/playground/gemini-3-8-flash-tts) - [API 文档](https://muapi.ai/zh/playground/gemini-3-8-flash-tts/api) - [全站 llms.txt](https://muapi.ai/zh/llms.txt)