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

# 文本转语音

> 将文本转换为音频



## OpenAPI

````yaml /api.json post /v1/audio/speech
openapi: 3.0.1
info:
  title: TKHub API
  description: TKHub 平台 API 接口文档
  version: 1.0.0
servers:
  - url: https://api.tkhub.ai
    description: 生产环境
  - url: https://api-test.tkhub.ai
    description: 测试环境
security:
  - bearerAuth: []
paths:
  /v1/audio/speech:
    post:
      tags:
        - OpenAI音频(Audio)
      summary: 文本转语音
      description: 将文本转换为音频
      operationId: createSpeech
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpeechRequest'
        required: true
      responses:
        '200':
          description: 成功生成音频
          content:
            audio/mpeg:
              schema:
                type: string
                format: binary
          headers: {}
      deprecated: false
      security:
        - BearerAuth: []
components:
  schemas:
    SpeechRequest:
      type: object
      required:
        - model
        - input
        - voice
      properties:
        model:
          type: string
          example: tts-1
        input:
          type: string
          description: 要转换的文本
          maxLength: 4096
        voice:
          type: string
          enum:
            - alloy
            - echo
            - fable
            - onyx
            - nova
            - shimmer
        response_format:
          type: string
          enum:
            - mp3
            - opus
            - aac
            - flac
            - wav
            - pcm
          default: mp3
        speed:
          type: number
          minimum: 0.25
          maximum: 4
          default: 1
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: |
        使用 Bearer Token 认证。
        格式: `Authorization: Bearer sk-xxxxxx`

````