# IndexTTS 扩展语音合成

> 音频生成

提交语音合成请求。请求中传入文本、音色和输出格式，响应返回音频内容。

## 请求地址

`POST https://api.modelverse.cn/v1/audio/speech`

## 请求体

## 响应

- **200** — Synthesized speech audio.
- **400** — 请求参数无效。
- **default** — 错误响应。

## OpenAPI 定义

```json
{
  "openapi": "3.1.0",
  "x-language": "zh-CN",
  "info": {
    "title": "IndexTeam-IndexTTS-extend接口文档",
    "version": "1.0.0",
    "description": "这是 ModelVerse 上 `IndexTeam-IndexTTS-extend` 的语音接口文档，说明如何提交语音合成请求、读取音频结果以及处理错误。\n接口路径包括 `POST /v1/audio/speech`。\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "ModelVerse API endpoint shown in the source examples."
    }
  ],
  "tags": [
    {
      "name": "IndexTeam IndexTTS Extend",
      "description": "IndexTeam/IndexTTS speech synthesis with UModelverse extension fields."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/audio/speech": {
      "post": {
        "tags": [
          "IndexTeam IndexTTS Extend"
        ],
        "operationId": "createIndexTeamIndexTTSExtendSpeech",
        "summary": "IndexTTS 扩展语音合成",
        "description": "提交语音合成请求。请求中传入文本、音色和输出格式，响应返回音频内容。\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IndexTeamIndexTTSExtendSpeechRequest"
              },
              "examples": {
                "happyBuiltinVoice": {
                  "summary": "Built-in voice带emotion text",
                  "value": {
                    "model": "IndexTeam/IndexTTS-2",
                    "input": "你好，这是一段带有愉快情绪的语音示例。",
                    "voice": "jack_cheng",
                    "sample_rate": 24000,
                    "gain": 1,
                    "emo_control_method": 1,
                    "emo_weight": 0.8,
                    "emo_text": "愉快",
                    "interval_silence": 200,
                    "max_text_tokens_per_sentence": 120
                  }
                },
                "customVoiceWithRandomEmotion": {
                  "summary": "Custom voice带emotion-vector control",
                  "value": {
                    "model": "IndexTeam/IndexTTS-2",
                    "input": "你好，我是带情绪的自定义音色示例。",
                    "voice": "uspeech:xxxx-xxxx-xxxx-xxxx",
                    "emo_control_method": 2,
                    "emo_weight": 0.6,
                    "emo_random": true,
                    "interval_silence": 200,
                    "max_text_tokens_per_sentence": 120
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Synthesized speech audio.",
            "content": {
              "audio/wav": {
                "schema": {
                  "$ref": "#/components/schemas/IndexTeamIndexTTSExtendAudioResponse"
                },
                "examples": {
                  "builtinVoiceSpeech": {
                    "summary": "WAV音频for a built-in voice 请求",
                    "value": "{binary WAV audio bytes}"
                  },
                  "customVoiceSpeech": {
                    "summary": "WAV音频for a custom voice 请求",
                    "value": "{binary WAV audio bytes}"
                  }
                }
              },
              "application/octet-stream": {
                "schema": {
                  "$ref": "#/components/schemas/IndexTeamIndexTTSExtendAudioResponse"
                },
                "examples": {
                  "speechFile": {
                    "summary": "Synthesized音频file bytes",
                    "value": "{binary audio bytes}"
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数无效。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IndexTeamIndexTTSExtendErrorResponse"
                },
                "examples": {
                  "invalidExtensionParameter": {
                    "$ref": "#/components/examples/IndexTeamIndexTTSExtendError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "错误响应。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IndexTeamIndexTTSExtendErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/IndexTeamIndexTTSExtendError"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "提交语音合成请求。请求中传入文本、音色和输出格式，响应返回音频内容。\n"
      }
    },
    "schemas": {
      "IndexTeamIndexTTSExtendSpeechRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "model",
          "input",
          "voice"
        ],
        "properties": {
          "model": {
            "$ref": "#/components/schemas/IndexTeamIndexTTSExtendModel"
          },
          "input": {
            "type": "string",
            "minLength": 1,
            "description": "Text to synthesize.",
            "examples": [
              "你好，欢迎使用 Modelverse TTS。"
            ]
          },
          "voice": {
            "type": "string",
            "minLength": 1,
            "description": "Voice to use for synthesis. The source examples show the built-in\n`jack_cheng` voice and custom voice IDs shaped like `uspeech:xxxx`.\n",
            "examples": [
              "jack_cheng",
              "uspeech:xxxx-xxxx-xxxx-xxxx"
            ]
          },
          "response_format": {
            "type": "string",
            "minLength": 1,
            "description": "OpenAI-compatible base TTS field mentioned by the source document.\nConcrete response-format values are not enumerated in this source.\n"
          },
          "speed": {
            "type": "number",
            "format": "double",
            "minimum": 0.25,
            "maximum": 4,
            "default": 1,
            "description": "Speech playback speed. The documented range is 0.25 to 4."
          },
          "instructions": {
            "type": "string",
            "description": "OpenAI-compatible base TTS field mentioned by the source document.\nThis source does not define additional IndexTTS-specific semantics.\n"
          },
          "sample_rate": {
            "type": "integer",
            "default": 22050,
            "description": "Target audio sample rate. Supported concrete values are defined by\nthe provider; the source lists examples such as 16000, 22050, and\n24000.\n",
            "examples": [
              16000,
              22050,
              24000
            ]
          },
          "gain": {
            "type": "number",
            "format": "double",
            "minimum": 0,
            "maximum": 10,
            "default": 1,
            "description": "Output volume gain coefficient. The source recommends the range\n`(0, 10]` and notes that `0` mutes output.\n"
          },
          "emo_control_method": {
            "type": "integer",
            "enum": [
              0,
              1,
              2,
              3
            ],
            "default": 0,
            "description": "Emotion-control method identifier. `0` disables emotion control,\n`1` uses emotion audio, `2` uses an emotion vector, and `3` uses\nemotion text.\n"
          },
          "emo_weight": {
            "type": "number",
            "format": "double",
            "minimum": 0,
            "maximum": 1,
            "default": 1,
            "description": "Weight applied to the emotion reference audio, vector, or text.\nThe documented valid range is 0.0 to 1.0. The source recommends\nabout 0.6 or lower for text emotion mode to produce more natural\nspeech.\n"
          },
          "emo_vec": {
            "type": "array",
            "minItems": 8,
            "maxItems": 8,
            "default": [
              0,
              0,
              0,
              0,
              0,
              0,
              0,
              0
            ],
            "description": "Emotion vector ordered as happiness, anger, sadness, fear,\ndisgust, melancholy, surprise, and calm. Each dimension is\ndocumented as 0 to 1.2, and the sum of all dimensions must not\nexceed 1.5.\n",
            "items": {
              "type": "number",
              "format": "double",
              "minimum": 0,
              "maximum": 1.2
            },
            "examples": [
              [
                0.8,
                0,
                0,
                0,
                0,
                0,
                0.1,
                0
              ]
            ]
          },
          "emo_text": {
            "type": "string",
            "default": "",
            "description": "Natural-language emotion prompt, such as happy, calm, or excited.",
            "examples": [
              "愉快",
              "平静",
              "激动"
            ]
          },
          "emo_random": {
            "type": "boolean",
            "default": false,
            "description": "Whether to introduce randomness into emotion control for more\nvariety or to avoid identical emotion expression between sentences.\n"
          },
          "interval_silence": {
            "type": "integer",
            "minimum": 0,
            "default": 200,
            "description": "Controls interval silence between sentences. The field table and\ncurl examples use a millisecond integer with a recommended value\nof 200.\n",
            "examples": [
              200,
              true
            ]
          },
          "max_text_tokens_per_sentence": {
            "type": "integer",
            "minimum": 1,
            "default": 120,
            "description": "Maximum token count or length threshold for internal sentence\nsplitting in long-text synthesis. The source recommends 120.\n"
          }
        }
      },
      "IndexTeamIndexTTSExtendModel": {
        "type": "string",
        "pattern": "^IndexTeam/IndexTTS(?:-.+)?$",
        "description": "提交语音合成请求。请求中传入文本、音色和输出格式，响应返回音频内容。\n",
        "examples": [
          "IndexTeam/IndexTTS-2"
        ]
      },
      "IndexTeamIndexTTSExtendAudioResponse": {
        "type": "string",
        "format": "binary",
        "description": "提交语音合成请求。请求中传入文本、音色和输出格式，响应返回音频内容。\n"
      },
      "IndexTeamIndexTTSExtendErrorResponse": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/IndexTeamIndexTTSExtendError"
          },
          "request_id": {
            "type": "string",
            "description": "Request identifier, if available."
          }
        }
      },
      "IndexTeamIndexTTSExtendError": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "message",
          "type"
        ],
        "properties": {
          "message": {
            "type": "string",
            "description": "错误信息。"
          },
          "type": {
            "type": "string",
            "description": "错误类型。",
            "examples": [
              "invalid_request_error"
            ]
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "description": "错误码。",
            "examples": [
              "param_error"
            ]
          },
          "param": {
            "type": [
              "string",
              "null"
            ],
            "description": "与错误相关的请求参数。",
            "examples": [
              "emo_weight"
            ]
          }
        }
      }
    },
    "examples": {
      "IndexTeamIndexTTSExtendError": {
        "summary": "Invalid extension parameter",
        "value": {
          "error": {
            "message": "Invalid param",
            "type": "invalid_request_error",
            "code": "param_error",
            "param": "emo_weight"
          },
          "request_id": "request_id"
        }
      }
    }
  }
}
```
