> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vmeg.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 合成语音（异步）

> 提交较长或批量的 TTS 任务。HTTP 仅返回受理信息（`taskId`）。完成后的音频通过 [Webhook](/zh/guides/webhooks) 回调投递（`event`: `openapi-tts`）。



## OpenAPI

````yaml /zh/api-reference/openapi.json post /openapi/v1/task/tts/create-async
openapi: 3.1.0
info:
  title: VMEG Open API
  description: >-
    将 VMEG 集成到产品中：翻译并配音视频或音频、语音合成、声音克隆、纯文本翻译，以及管理 API 侧文件。响应格式为 `{ code,
    message, data }`；`code === 200` 表示成功。
  version: 1.0.0
servers:
  - url: https://api.vmeg.ai
    description: 生产环境
security:
  - apiKeyAuth: []
tags:
  - name: 媒体翻译
    x-group: 视频与音频翻译配音
    description: >-
      对上传的视频或音频做端到端本地化：识别语音、翻译文稿、生成 AI 配音（克隆或预设音色），并返回配音后的媒体。可选字幕与口型同步。**仅异步** —
      配音文件通过 [Webhook](/zh/guides/webhooks) 投递。这不是纯文本翻译；见
      [媒体翻译](/zh/guides/products/media-translation)。
  - name: TTS
    x-group: 文本转语音（TTS）
    description: >-
      用预设或克隆音色将文本合成为自然语音。**同步**在 HTTP 响应中返回音频 URL；**异步**通过
      [Webhook](/zh/guides/webhooks) 投递结果。见
      [文本转语音](/zh/guides/products/text-to-speech)。
  - name: 声音克隆
    x-group: 声音克隆
    description: >-
      从短参考录音创建可复用音色，返回可用于 TTS 或翻译配音任务的 `voiceId`。见
      [声音克隆](/zh/guides/products/voice-clone)。
  - name: 文本翻译
    x-group: 文本翻译（仅文本）
    description: >-
      翻译纯文本片段，不处理音频或视频。媒体中的口语内容请使用 **视频与音频翻译配音**。见
      [文本翻译](/zh/guides/products/text-translation)。
  - name: 任务管理
    x-group: 任务状态与历史
    description: >-
      列出、查看或删除通过各产品 API 创建的任务。无法依赖 Webhook 时可轮询 `GET .../tasks/detail`。范围限定于当前
      **API Key**。见 [产品概览](/zh/guides/products/overview)。
  - name: 资产 - 素材
    x-group: 上传文件（素材）
    description: >-
      上传并管理用于翻译配音任务的视频/音频。流程：预签名上传 → 登记素材 → 将 `materialId` 传入 create-async。见
      [素材上传](/zh/guides/assets/material-upload)。
  - name: 资产 - 音色
    x-group: 音色（预设与克隆）
    description: 列出 TTS 预设音色，或管理已克隆音色。克隆音色通过 **声音克隆** 创建。见 [音色](/zh/guides/assets/voices)。
paths:
  /openapi/v1/task/tts/create-async:
    post:
      tags:
        - TTS
      summary: 合成语音（异步）
      description: >-
        提交较长或批量的 TTS 任务。HTTP 仅返回受理信息（`taskId`）。完成后的音频通过
        [Webhook](/zh/guides/webhooks) 回调投递（`event`: `openapi-tts`）。
      operationId: ttsCreateAsync
      parameters:
        - $ref: '#/components/parameters/IdempotencyKeyRequired'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenApiTtsCreateAsyncRequest'
      responses:
        '200':
          description: >-
            仅返回受理信息（`taskId`、`createdAt`）。最终生成结果在 [Webhook](/zh/guides/webhooks)
            回调请求体中。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenApiTaskAcceptedResponse'
      callbacks:
        taskCompleted:
          https://{yourWebhookUrl}:
            post:
              summary: '异步任务完成时的 Webhook（`event`: `openapi-tts`）'
              description: >-
                文本转语音异步任务完成时，VMEG 向你方 [Webhook](/zh/guides/webhooks) URL POST
                的**请求体**。JSON 中 `event` 为 `openapi-tts`（见 [Webhook
                请求体](/zh/guides/webhook-request)）。不属于上方 create-async
                **Response**。完整 schema：[创建
                TTS（异步）](/zh/api-reference/tts/create-tts-async) →
                **Callbacks**。
              parameters:
                - $ref: '#/components/parameters/CallbackTimestamp'
                - $ref: '#/components/parameters/CallbackSignature'
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      $ref: '#/components/schemas/OpenApiTtsTaskCompletedCallback'
              responses:
                '200':
                  description: 请尽快返回 2xx 以停止重试
              method: post
              type: path
            path: https://{yourWebhookUrl}
components:
  parameters:
    IdempotencyKeyRequired:
      name: X-Idempotency-Key
      in: header
      required: true
      description: 创建任务或修改持久化数据的 `POST` 必填（最长 64 字符）。见 [幂等](/zh/guides/idempotency)。
      schema:
        type: string
        maxLength: 64
    CallbackTimestamp:
      name: X-Timestamp
      in: header
      required: true
      description: Unix 时间戳（毫秒，字符串）
      schema:
        type: string
    CallbackSignature:
      name: X-Signature
      in: header
      required: true
      description: 小写十六进制 HMAC-SHA256(secret, X-Timestamp + 原始请求体)
      schema:
        type: string
  schemas:
    OpenApiTtsCreateAsyncRequest:
      allOf:
        - $ref: '#/components/schemas/OpenApiTtsCreateRequest'
        - type: object
          properties:
            extraData:
              $ref: '#/components/schemas/OpenApiExtraData'
    OpenApiTaskAcceptedResponse:
      allOf:
        - $ref: '#/components/schemas/OpenApiResponseBase'
        - type: object
          properties:
            data:
              $ref: '#/components/schemas/OpenApiTaskAcceptedData'
    OpenApiTtsTaskCompletedCallback:
      description: >-
        `event` 为 `openapi-tts` 时的 TTS Webhook **请求体**；`data` 含
        `results`、`taskId`。见 [Webhook 请求体](/zh/guides/webhook-request) 与 [创建
        TTS（异步）](/zh/api-reference/tts/create-tts-async) → **Callbacks**。
      allOf:
        - $ref: '#/components/schemas/OpenApiCallbackEnvelope'
        - type: object
          required:
            - data
          properties:
            data:
              description: '`event` 为 `openapi-tts` 时的产品结果；`data` 含 `results`、`taskId`。'
              allOf:
                - $ref: '#/components/schemas/OpenApiTtsCreateData'
    OpenApiTtsCreateRequest:
      type: object
      required:
        - data
      properties:
        provider:
          type: string
          deprecated: true
          description: >-
            已弃用 — 请勿传入。请在每行传入 `voiceId`。见
            [文本转语音](/zh/guides/products/text-to-speech) 与
            [支持的克隆方式](/zh/guides/supported-clone-methods#文本转语音voiceid-与组批规则)。
        language:
          type: object
          properties:
            target:
              type: string
              example: en-US
              description: 目标语言 locale（BCP-47）。见 [支持的语言](/zh/guides/supported-languages)。
          description: 合成目标语言
        trim:
          type: boolean
          default: false
          description: 为 `true` 时裁剪输出音频首尾静音
        data:
          type: array
          maxItems: 50
          items:
            $ref: '#/components/schemas/OpenApiTtsDataItem'
          description: >-
            待合成文本（最多 50 条）。每条需 `text` 及 [音色](/zh/guides/assets/voices) 中的
            `voiceId` 或 `timbreRefAudio`
        outputFormat:
          type: string
          enum:
            - wav
            - mp3
            - m4a
          default: m4a
          description: 输出音频格式：`wav`、`mp3` 或 `m4a`
    OpenApiExtraData:
      type: object
      additionalProperties: true
      description: 异步提交时的可选客户端元数据；任务完成时在 Webhook 回调体 `extraData` 中回显。同步创建接口不使用。
    OpenApiResponseBase:
      type: object
      properties:
        code:
          type: integer
          example: 200
          description: 业务码；200 表示成功
        message:
          type: string
          example: ''
          description: 当 `code` 非成功时的说明信息
      required:
        - code
    OpenApiTaskAcceptedData:
      type: object
      description: 异步提交后的立即响应（不含任务结果）
      required:
        - taskId
      properties:
        taskId:
          type: string
          description: Open API 任务 ID，可用于轮询或关联
        createdAt:
          type: string
          description: TTS 与文本翻译异步创建接口返回
    OpenApiCallbackEnvelope:
      type: object
      description: >-
        异步任务完成时 Webhook POST 的公共顶层字段。`event` 取值与各产品说明见 [Webhook
        请求体](/zh/guides/webhook-request)。
      properties:
        code:
          type: integer
          example: 200
          description: 本次投递的业务结果码
        version:
          type: string
          example: v1
          description: 任务的 API 版本号（如 `v1`、`v2`），与请求路径中的版本一致（如 `/openapi/v1/...`）。
        event:
          type: string
          enum:
            - openapi-tts
            - openapi-translate
            - openapi-clone-voice
            - openapi-media-translation
          example: openapi-tts
          description: >-
            已完成的产品类型。请按此值路由：`openapi-tts`（TTS）、`openapi-translate`（文本翻译）、`openapi-clone-voice`（声音克隆）、`openapi-media-translation`（音视频翻译）。详见
            [Webhook 请求体](/zh/guides/webhook-request)。
        pipelineKey:
          type: string
          example: a1b2c3d4e5f6789012345678901234ab
          description: >-
            该次异步完成的稳定标识。请用此字段对接收端去重 — 见 [Webhook
            请求体](/zh/guides/webhook-request#按-pipelinekey-去重)。
        message:
          type: string
          description: 当 `code` 非成功时的说明
        extraData:
          type: object
          additionalProperties: true
          description: 与异步提交请求中的 `extraData` 一致
    OpenApiTtsCreateData:
      type: object
      properties:
        taskId:
          type: string
          description: Open API 任务 ID
        results:
          type: array
          items:
            $ref: '#/components/schemas/OpenApiTtsResultItem'
          description: 合成结果条目
        createdAt:
          type: string
          description: 任务创建时间（ISO 8601）
    OpenApiTtsDataItem:
      type: object
      required:
        - text
      properties:
        text:
          type: string
          description: 待合成文本
        voiceId:
          type: string
          description: >-
            本行使用的系统或克隆音色 ID。见 [音色](/zh/guides/assets/voices)；也可改用
            `timbreRefAudio`
        timbreRefAudio:
          type: string
          description: 未使用 [音色](/zh/guides/assets/voices) 中 `voiceId` 时的参考音频 URL（HTTPS）
        emoWeight:
          type: number
          minimum: 0
          maximum: 1
          description: 情感强度，配合 `emoRefAudio` / `emoPrompt` 使用（0–1）
        emoRefAudio:
          type: string
          description: 用于情感或演绎风格的参考音频 URL（HTTPS）
        emoPrompt:
          type: string
          description: 描述期望情感或说话风格的文本提示
        duration:
          type: number
          description: 目标时长（秒）
    OpenApiTtsResultItem:
      type: object
      properties:
        uri:
          type: string
          description: 合成音频 URL（HTTPS）
        duration:
          type: number
          description: 时长（秒）
        errorMessage:
          type: string
          description: 该条合成失败时的原因
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      description: >-
        在 **`Authorization`** 请求头中传入 API Key（`Bearer <api_key>`）。见
        [鉴权](/zh/guides/authentication)。

````