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

# テキストを音声に変換

> テキストを音声に変換します。



## OpenAPI

````yaml /ja/api-reference/openapi_completion.json post /text-to-audio
openapi: 3.0.1
info:
  title: Completion アプリ API
  description: テキスト生成アプリケーションはセッションなしで動作し、翻訳、記事作成、要約 AI などに最適です。
  version: 1.0.0
servers:
  - url: https://{api_base_url}
    description: テキスト生成アプリ API のベース URL です。セルフホスト環境では、独自の API ベース URL に置き換えてください。
    variables:
      api_base_url:
        default: api.dify.ai/v1
        description: API ベース URL のホストとパス（`https://` を除く）。
security:
  - ApiKeyAuth: []
tags:
  - name: 完了メッセージ
    description: テキスト生成に関連する操作です。
  - name: ファイル操作
    description: ファイル管理に関連する操作です。
  - name: エンドユーザー
    description: エンドユーザー情報に関連する操作です。
  - name: メッセージフィードバック
    description: ユーザーフィードバックに関連する操作です。
  - name: 音声・テキスト変換
    description: テキスト読み上げと音声認識に関連する操作です。
  - name: アプリケーション設定
    description: アプリケーション設定と情報を取得する操作です。
paths:
  /text-to-audio:
    post:
      tags:
        - 音声・テキスト変換
      summary: テキストを音声に変換
      description: テキストを音声に変換します。
      operationId: textToAudioCompletionJp
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TextToAudioRequest'
            examples:
              textToAudioExample:
                summary: リクエスト例
                value:
                  text: Hello, welcome to our service.
                  user: abc-123
                  voice: alloy
                  streaming: false
      responses:
        '200':
          description: >-
            生成された音声ファイルを返します。`Content-Type` ヘッダーは音声の MIME
            タイプ（例：`audio/wav`、`audio/mp3`）に設定されます。`streaming` が `true`
            の場合、音声はチャンク転送エンコーディングでストリーミングされます。
          content:
            audio/mpeg:
              schema:
                type: string
                format: binary
        '400':
          description: |-
            - `app_unavailable` : アプリケーションが利用できないか、設定が正しくありません。
            - `provider_not_initialize` : 有効なモデルプロバイダーの認証情報が見つかりません。
            - `provider_quota_exceeded` : モデルプロバイダーのクォータが使い切られました。
            - `model_currently_not_support` : 現在のモデルはこの操作をサポートしていません。
            - `completion_request_error` : テキスト読み上げリクエストに失敗しました。
          content:
            application/json:
              examples:
                app_unavailable:
                  summary: app_unavailable
                  value:
                    status: 400
                    code: app_unavailable
                    message: App unavailable, please check your app configurations.
                provider_not_initialize:
                  summary: provider_not_initialize
                  value:
                    status: 400
                    code: provider_not_initialize
                    message: >-
                      No valid model provider credentials found. Please go to
                      Settings -> Model Provider to complete your provider
                      credentials.
                provider_quota_exceeded:
                  summary: provider_quota_exceeded
                  value:
                    status: 400
                    code: provider_quota_exceeded
                    message: >-
                      Your quota for Dify Hosted OpenAI has been exhausted.
                      Please go to Settings -> Model Provider to complete your
                      own provider credentials.
                model_currently_not_support:
                  summary: model_currently_not_support
                  value:
                    status: 400
                    code: model_currently_not_support
                    message: >-
                      Dify Hosted OpenAI trial currently not support the GPT-4
                      model.
                completion_request_error:
                  summary: completion_request_error
                  value:
                    status: 400
                    code: completion_request_error
                    message: Completion request failed.
        '500':
          description: '`internal_server_error` : 内部サーバーエラー。'
          content:
            application/json:
              examples:
                internal_server_error:
                  summary: internal_server_error
                  value:
                    status: 500
                    code: internal_server_error
                    message: Internal server error.
components:
  schemas:
    TextToAudioRequest:
      type: object
      description: テキストから音声への変換のリクエストボディ。`message_id` または `text` のいずれかを指定してください。
      properties:
        message_id:
          type: string
          format: uuid
          description: メッセージ ID です。両方が指定された場合、`text` よりも優先されます。
        text:
          type: string
          description: 変換する音声コンテンツ。
        user:
          type: string
          description: ユーザー識別子。
        voice:
          type: string
          description: >-
            テキスト読み上げに使用する音声。利用可能な音声は、このアプリに設定された TTS
            プロバイダーによって異なります。デフォルトには[アプリケーションのパラメータ情報を取得](/api-reference/アプリケーション設定/アプリケーションのパラメータ情報を取得)
            → `text_to_speech.voice` の `voice` 値を使用してください。
        streaming:
          type: boolean
          description: ストリーミングレスポンスを有効にするかどうか。
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        API Key 認証です。すべての API リクエストにおいて、`Authorization` HTTP ヘッダーに `Bearer `
        プレフィックスを付けた API Key を含めてください。例：`Authorization: Bearer {API_KEY}`。**API
        Key はサーバーサイドに保存し、クライアントサイドで共有・保存しないことを強く推奨します。API Key
        の漏洩は深刻な結果につながる可能性があります。**

````