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

# 文本转语音

> 使用 `GLM-TTS` 将文本转换为自然语音，支持多种声音、情感控制和语调调整。点击 **Try it** 按钮可快速试用。



## OpenAPI

````yaml /openapi/openapi.json post /paas/v4/audio/speech
openapi: 3.0.1
info:
  title: ZHIPU AI API
  description: ZHIPU AI 接口提供强大的 AI 能力，包括聊天对话、工具调用和视频生成。
  license:
    name: ZHIPU AI 开发者协议和政策
    url: https://chat.z.ai/legal-agreement/terms-of-service
  version: 1.0.0
  contact:
    name: Z.AI 开发者
    url: https://chat.z.ai/legal-agreement/privacy-policy
    email: user_feedback@z.ai
servers:
  - url: https://open.bigmodel.cn/api/
    description: 开放平台服务
security:
  - bearerAuth: []
tags:
  - name: 模型 API
    description: Chat API
  - name: 工具 API
    description: Web Search API
  - name: Agent API
    description: Agent API
  - name: 文件 API
    description: File API
  - name: 知识库 API
    description: Knowledge API
  - name: 实时 API
    description: Realtime API
  - name: 批处理 API
    description: Batch API
  - name: 助理 API
    description: Assistant API
  - name: 智能体 API（旧）
    description: QingLiu Agent API
paths:
  /paas/v4/audio/speech:
    post:
      tags:
        - 模型 API
      summary: 文本转语音
      description: 使用 `GLM-TTS` 将文本转换为自然语音，支持多种声音、情感控制和语调调整。点击 **Try it** 按钮可快速试用。
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AudioSpeechRequest'
            examples:
              文本转语音示例:
                value:
                  model: glm-tts
                  input: 你好，今天天气怎么样.
                  voice: tongtong
                  response_format: wav
        required: true
      responses:
        '200':
          description: |-
            业务处理成功 
             - 采样率建议设置为24000
          content:
            audio/wav:
              schema:
                type: string
                format: binary
        default:
          description: 请求失败。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    AudioSpeechRequest:
      type: object
      required:
        - model
        - input
        - voice
      properties:
        model:
          type: string
          enum:
            - glm-tts
          default: glm-tts
          description: 要使用的`TTS`模型
        input:
          type: string
          description: 要转换为语音的文本
          default: 你好，今天天气怎么样
          maxLength: 1024
        voice:
          type: string
          enum:
            - tongtong
            - chuichui
            - xiaochen
            - jam
            - kazi
            - douji
            - luodo
          default: tongtong
          description: |-
            生成音频时使用的音色，支持系统音色以及复刻音色两种类型，其中系统音色如下：
            `tongtong`: 彤彤，默认音色 
            `chuichui`: 锤锤 
            `xiaochen`: 小陈 
            `jam`: 动动动物圈`jam`音色 
            `kazi`: 动动动物圈`kazi`音色 
            `douji`: 动动动物圈`douji`音色 
            `luodo`: 动动动物圈`luodo`音色
        watermark_enabled:
          type: boolean
          description: |-
            控制`AI`生成音频时是否添加水印。去水印操作路径：右上角个人中心-安全管理-去水印管理-打开开关。
             - `true`: 默认启用`AI`生成的显式水印及隐式数字水印，符合政策要求。
             - `false`: 关闭所有水印，仅对已完成去水印动作的用户生效。
          example: true
        stream:
          type: boolean
          default: false
          description: |-
            是否启用流式输出。
            - `true`: 启用流式输出，模型将通过标准`Event Stream`逐块返回生成的音频内容。
            - `false`: 关闭流式输出，模型在生成所有内容后一次性返回所有内容。默认值为`false`。
        speed:
          type: number
          description: 语速，默认1.0，取值范围[0.5, 2]
        volume:
          type: number
          description: 音量，默认1.0，取值范围(0, 10]
        encode_format:
          type: string
          enum:
            - base64
            - hex
          description: 仅流式返回时，决定返回的编码格式。默认返回对应音频文件格式的`base64`字符串。
        response_format:
          type: string
          enum:
            - wav
            - pcm
          default: pcm
          description: 音频输出格式，默认返回`pcm`格式的文件。流式生成音频时，仅支持返回`pcm`格式的文件
    Error:
      type: object
      properties:
        error:
          required:
            - code
            - message
          type: object
          properties:
            code:
              type: string
            message:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        标准的 HTTP Bearer 认证方式，在 [API
        Keys](https://bigmodel.cn/usercenter/proj-mgmt/apikeys) 页面获取密钥。

````