同步语音合成 V2

POST /minimax/v1/t2a_v2

MethodPOST
Path/minimax/v1/t2a_v2
Typehttp
Status1
Module2102810
Folder78007621

说明

概览

MethodPOST
Path/minimax/v1/t2a_v2
Typehttp
Status1
Module2102810
Folder78007621

参数

{
  "query": [],
  "path": [],
  "cookie": [],
  "header": [
    {
      "id": "5UQxpCXpXb",
      "name": "Content-Type",
      "required": true,
      "enable": true,
      "description": "请求体的媒介类型,必须设置为 application/json 以确保请求数据的格式为 JSON",
      "type": "string",
      "schema": {
        "type": "string",
        "enum": [
          "application/json"
        ],
        "default": "application/json"
      },
      "sampleValue": ""
    }
  ]
}

请求体

{
  "type": "application/json",
  "parameters": [],
  "jsonSchema": {
    "type": "object",
    "properties": {}
  },
  "required": true,
  "mediaType": "application/json",
  "examples": [
    {
      "name": "最简单的语音合成示例",
      "value": "{\n    \"model\": \"speech-02-hd\",\n    \"text\": \"你好,欢迎使用语音合成服务!\",\n    \"voice_setting\": {\n        \"voice_id\": \"moss_audio_ce44fc67-7ce3-11f0-8de5-96e35d26fb85\"\n    }\n}",
      "oasKey": "基础非流式合成",
      "oasExtensions": "",
      "mediaType": "application/json"
    },
    {
      "name": "使用语气词标签增强表现力",
      "value": "{\n    \"model\": \"speech-2.8-hd\",\n    \"text\": \"今天是不是很开心呀(laughs),当然了(breath)!\",\n    \"stream\": false,\n    \"voice_setting\": {\n        \"voice_id\": \"male-qn-qingse\",\n        \"speed\": 1,\n        \"vol\": 1,\n        \"pitch\": 0,\n        \"emotion\": \"happy\"\n    },\n    \"pronunciation_dict\": {\n        \"tone\": [\n            \"处理/(chu3)(li3)\",\n            \"危险/dangerous\"\n        ]\n    },\n    \"audio_setting\": {\n        \"sample_rate\": 32000,\n        \"bitrate\": 128000,\n        \"format\": \"mp3\",\n        \"channel\": 1\n    },\n    \"subtitle_enable\": false\n}",
      "oasKey": "带语气词的合成",
      "oasExtensions": "",
      "mediaType": "application/json"
    },
    {
      "name": "流式输出可以更快地获得音频反馈",
      "value": "{\n    \"model\": \"speech-2.8-turbo\",\n    \"text\": \"这是一段较长的文本,使用流式输出可以边合成边播放,减少等待时间。\",\n    \"stream\": true,\n    \"stream_options\": {\n        \"exclude_aggregated_audio\": false\n    },\n    \"voice_setting\": {\n        \"voice_id\": \"English_Graceful_Lady\",\n        \"speed\": 1.2\n    },\n    \"audio_setting\": {\n        \"format\": \"mp3\",\n        \"force_cbr\": true\n    }\n}",
      "oasKey": "流式输出",
      "oasExtensions": "",
      "mediaType": "application/json"
    },
    {
      "name": "使用多种音色混合创造独特声音",
      "value": "{\n    \"model\": \"speech-2.6-hd\",\n    \"text\": \"这是使用混合音色的语音合成示例。\",\n    \"voice_setting\": {\n        \"voice_id\": \"\",\n        \"speed\": 1,\n        \"vol\": 1\n    },\n    \"timber_weights\": [\n        {\n            \"voice_id\": \"female-chengshu\",\n            \"weight\": 30\n        },\n        {\n            \"voice_id\": \"female-tianmei\",\n            \"weight\": 70\n        }\n    ]\n}",
      "oasKey": "混合音色",
      "oasExtensions": "",
      "mediaType": "application/json"
    },
    {
      "name": "使用声音效果器调整音色特征",
      "value": "{\n    \"model\": \"speech-2.6-hd\",\n    \"text\": \"这是带声音效果器的语音合成。\",\n    \"voice_setting\": {\n        \"voice_id\": \"English_Persuasive_Man\"\n    },\n    \"voice_modify\": {\n        \"pitch\": 20,\n        \"intensity\": -30,\n        \"timbre\": 10,\n        \"sound_effects\": \"robotic\"\n    }\n}",
      "oasKey": "声音效果器",
      "oasExtensions": "",
      "mediaType": "application/json"
    }
  ],
  "oasExtensions": ""
}

响应

[
  {
    "id": 197820744,
    "name": "",
    "code": 200,
    "contentType": "json",
    "jsonSchema": {
      "type": "object",
      "properties": {}
    },
    "itemSchema": {},
    "description": "成功响应,返回合成的音频数据(hex 编码或 URL)以及相关统计信息",
    "mediaType": "application/json",
    "headers": [],
    "oasExtensions": "",
    "additionalContent": [
      {
        "contentType": "eventStream",
        "mediaType": "text/event-stream",
        "jsonSchema": {
          "$ref": "#/components/schemas/T2aV2StreamResponse"
        },
        "examples": {
          "流式响应": {
            "summary": "流式输出时的分块响应",
            "value": "data: {\"data\":{\"audio\":\"hex编码的audio_chunk1\",\"status\":1},\"trace_id\":\"01b8bf9bb7433cc75c18eee6cfa8fe21\",\"base_resp\":{\"status_code\":0,\"status_msg\":\"\"}}\n\ndata: {\"data\":{\"audio\":\"hex编码的audio_chunk2\",\"status\":1},\"trace_id\":\"01b8bf9bb7433cc75c18eee6cfa8fe21\",\"base_resp\":{\"status_code\":0,\"status_msg\":\"\"}}\n\ndata: {\"data\":{\"audio\":\"hex编码的完整audio\",\"status\":2},\"extra_info\":{\"audio_length\":6931,\"audio_sample_rate\":32000,\"audio_size\":111789,\"bitrate\":128000,\"word_count\":112,\"usage_characters\":112},\"trace_id\":\"04ece790375f3ca2edbb44e8c4c200bf\",\"base_resp\":{\"status_code\":0,\"status_msg\":\"success\"}}\n\ndata: [DONE]"
          }
        }
      }
    ]
  },
  {
    "id": 180103289,
    "name": "",
    "code": 400,
    "contentType": "json",
    "jsonSchema": {
      "type": "object",
      "properties": {}
    },
    "itemSchema": {},
    "description": "请求参数错误",
    "mediaType": "application/json",
    "headers": [],
    "oasExtensions": ""
  },
  {
    "id": 189185689,
    "name": "",
    "code": 401,
    "contentType": "json",
    "jsonSchema": {
      "type": "object",
      "properties": {}
    },
    "itemSchema": {},
    "description": "鉴权失败",
    "mediaType": "application/json",
    "headers": [],
    "oasExtensions": ""
  },
  {
    "id": 111830522,
    "name": "",
    "code": 429,
    "contentType": "json",
    "jsonSchema": {
      "type": "object",
      "properties": {}
    },
    "itemSchema": {},
    "description": "触发限流",
    "mediaType": "application/json",
    "headers": [],
    "oasExtensions": ""
  }
]

响应示例

[
  {
    "name": "非流式合成完成后的完整响应",
    "responseId": 197820744,
    "data": "{\n    \"data\": {\n        \"audio\": \"2f2f2f2f504b0304...\",\n        \"status\": 2\n    },\n    \"extra_info\": {\n        \"audio_length\": 9900,\n        \"audio_sample_rate\": 32000,\n        \"audio_size\": 160323,\n        \"bitrate\": 128000,\n        \"word_count\": 52,\n        \"invisible_character_ratio\": 0,\n        \"usage_characters\": 26,\n        \"audio_format\": \"mp3\",\n        \"audio_channel\": 1\n    },\n    \"trace_id\": \"01b8bf9bb7433cc75c18eee6cfa8fe21\",\n    \"base_resp\": {\n        \"status_code\": 0,\n        \"status_msg\": \"success\"\n    }\n}",
    "description": "",
    "oasKey": "非流式成功响应",
    "oasExtensions": "",
    "id": "019c27fa-d682-7649-8323-a5eaa84a4726"
  },
  {
    "name": "启用字幕功能后的响应",
    "responseId": 197820744,
    "data": "{\n    \"data\": {\n        \"audio\": \"2f2f2f2f504b0304...\",\n        \"subtitle_file\": \"https://filecdn.minimax.chat/subtitle/subtitle_123.json\",\n        \"status\": 2\n    },\n    \"extra_info\": {\n        \"audio_length\": 12000,\n        \"audio_sample_rate\": 32000,\n        \"audio_size\": 195000,\n        \"word_count\": 68,\n        \"usage_characters\": 68\n    },\n    \"trace_id\": \"subtitle_example_123\",\n    \"base_resp\": {\n        \"status_code\": 0,\n        \"status_msg\": \"success\"\n    }\n}",
    "description": "",
    "oasKey": "带字幕的响应",
    "oasExtensions": "",
    "id": "019c27fa-d682-7649-8323-a881d8dc9f12"
  },
  {
    "name": "参数错误",
    "responseId": 180103289,
    "data": "{\n    \"base_resp\": {\n        \"status_code\": 2013,\n        \"status_msg\": \"输入参数信息不正常:voice_id 不能为空\"\n    }\n}",
    "description": "",
    "oasKey": "参数错误",
    "oasExtensions": "",
    "id": "019c27fa-d682-7649-8323-ae264950562d"
  },
  {
    "name": "鉴权失败",
    "responseId": 189185689,
    "data": "{\n    \"base_resp\": {\n        \"status_code\": 1004,\n        \"status_msg\": \"鉴权失败,请检查 API-Key 是否正确\"\n    }\n}",
    "description": "",
    "oasKey": "鉴权失败",
    "oasExtensions": "",
    "id": "019c27fa-d682-7649-8323-b11cc81451ec"
  },
  {
    "name": "触发限流",
    "responseId": 111830522,
    "data": "{\n    \"base_resp\": {\n        \"status_code\": 1002,\n        \"status_msg\": \"触发限流,请稍后再试\"\n    }\n}",
    "description": "",
    "oasKey": "触发限流",
    "oasExtensions": "",
    "id": "019c27fa-d682-7649-8323-b75e6ac416b2"
  }
]