> ## Documentation Index
> Fetch the complete documentation index at: https://dify-6c0370d8-fix-template-upload-size-guidance.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# テキストを音声に変換

> **対象アプリ**：Chatflow、Workflow、Agent、チャットボット、レガシー Agent、テキストジェネレーター。

テキストを音声に変換します。任意のテキストを合成するには `text` を、既存のメッセージの回答を音声化するには `message_id` を渡します。



## OpenAPI

````yaml /ja/api-reference/openapi_service.json post /text-to-audio
openapi: 3.0.1
info:
  description: >-
    Dify アプリケーションとナレッジベースのための REST API です。アプリケーション系エンドポイントはアプリの API
    キーで、ナレッジ系エンドポイントはナレッジベースの API キーで認証します。
  title: Dify サービス API
  version: 1.0.0
servers:
  - description: Dify サービス API のベース URL です。セルフホスト環境では、独自の API ベース URL に置き換えてください。
    url: https://{api_base_url}
    variables:
      api_base_url:
        default: api.dify.ai/v1
        description: API ベース URL のホストとパス（`https://` を除く）。
security:
  - ApiKeyAuth: []
tags:
  - description: チャットメッセージとインタラクションに関連する操作です。
    name: チャットメッセージ
  - description: ファイルのアップロードとプレビューの操作です。
    name: ファイル操作
  - description: エンドユーザー情報に関連する操作です。
    name: エンドユーザー
  - description: ユーザーフィードバックの操作です。
    name: メッセージフィードバック
  - description: 会話管理に関連する操作です。
    name: 会話管理
  - description: テキスト読み上げと音声認識の操作です。
    name: 音声・テキスト変換
  - description: アプリケーション設定と情報を取得する操作です。
    name: アプリケーション設定
  - description: ダイレクト返信用のアノテーション管理に関連する操作です。
    name: アノテーション管理
  - description: 人間の入力を要する一時停止中のワークフローの再開操作です。
    name: 人間の入力
  - description: ワークフローの実行と管理のための操作です。
    name: ワークフロー実行
  - description: テキスト生成に関連する操作です。
    name: 完了メッセージ
  - description: ナレッジベースの作成、設定、取得を含むナレッジベース管理の操作です。
    name: ナレッジベース
  - description: ナレッジベース内のドキュメントの作成、更新、管理のための操作です。
    name: ドキュメント
  - description: ドキュメントチャンクと子チャンクの管理のための操作です。
    name: チャンク
  - description: ナレッジベースのメタデータフィールドとドキュメントメタデータ値の管理のための操作です。
    name: メタデータ
  - description: ナレッジベースタグとタグバインディングの管理のための操作です。
    name: タグ管理
  - description: 利用可能なモデルを取得するための操作です。
    name: モデル
  - description: データソースプラグインとパイプライン実行を含むナレッジパイプラインの管理と実行のための操作です。
    name: ナレッジパイプライン
paths:
  /text-to-audio:
    post:
      tags:
        - 音声・テキスト変換
      summary: テキストを音声に変換
      description: >-
        **対象アプリ**：Chatflow、Workflow、Agent、チャットボット、レガシー Agent、テキストジェネレーター。


        テキストを音声に変換します。任意のテキストを合成するには `text` を、既存のメッセージの回答を音声化するには `message_id`
        を渡します。
      operationId: basicChatTextToAudioJa
      requestBody:
        content:
          application/json:
            examples:
              textToAudioExample:
                summary: リクエスト例
                value:
                  streaming: false
                  text: Hello, welcome to our service.
                  user: abc-123
                  voice: alloy
            schema:
              $ref: '#/components/schemas/TextToAudioRequest'
        required: true
      responses:
        '200':
          content:
            audio/aac:
              schema:
                format: binary
                type: string
            audio/flac:
              schema:
                format: binary
                type: string
            audio/mp4:
              schema:
                format: binary
                type: string
            audio/mpeg:
              schema:
                format: binary
                type: string
            audio/ogg:
              schema:
                format: binary
                type: string
            audio/wav:
              schema:
                format: binary
                type: string
            audio/webm:
              schema:
                format: binary
                type: string
          description: >-
            生成された音声を返します。`Content-Type`
            ヘッダーはプロバイダーが返す音声コンテナ形式を反映し、認識可能な場合はレスポンスのバイト列から検証されます。


            レスポンスボディは AAC、FLAC、MP4、MP3、Ogg、WAV、WebM
            のいずれかです。認識できない出力には、プロバイダーが宣言した形式が設定されます。宣言がない場合は `audio/mpeg` になります。


            プロバイダーがストリームを返す場合はチャンク転送エンコーディングで配信されます。リクエストの `streaming`
            フィールドはこの動作を制御しません。
        '400':
          content:
            application/json:
              examples:
                app_unavailable:
                  summary: app_unavailable
                  value:
                    code: app_unavailable
                    message: App unavailable, please check your app configurations.
                    status: 400
                completion_request_error:
                  summary: completion_request_error
                  value:
                    code: completion_request_error
                    message: Completion request failed.
                    status: 400
                invalid_param:
                  summary: invalid_param
                  value:
                    code: invalid_param
                    message: TTS is not enabled
                    status: 400
                model_currently_not_support:
                  summary: model_currently_not_support
                  value:
                    code: model_currently_not_support
                    message: >-
                      Dify Hosted OpenAI trial currently not support the GPT-4
                      model.
                    status: 400
                provider_not_initialize:
                  summary: provider_not_initialize
                  value:
                    code: provider_not_initialize
                    message: >-
                      No valid model provider credentials found. Please go to
                      Settings -> Model Provider to complete your provider
                      credentials.
                    status: 400
                provider_quota_exceeded:
                  summary: provider_quota_exceeded
                  value:
                    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.
                    status: 400
          description: >-
            - `app_unavailable` : アプリケーションが利用できないか、設定が正しくありません。

            - `invalid_param` : テキスト読み上げが有効になっていない、`text`
            が指定されていない、または利用可能な音声がありません。

            - `provider_not_initialize` : 有効なモデルプロバイダーの認証情報が見つかりません。

            - `provider_quota_exceeded` : モデルプロバイダーのクォータが使い切られました。

            - `model_currently_not_support` : 現在のモデルはこの操作をサポートしていません。

            - `completion_request_error` : テキスト読み上げリクエストに失敗しました。
        '500':
          content:
            application/json:
              examples:
                internal_server_error:
                  summary: internal_server_error
                  value:
                    code: internal_server_error
                    message: >-
                      The server encountered an internal error and was unable to
                      complete your request. Either the server is overloaded or
                      there is an error in the application.
                    status: 500
          description: '`internal_server_error` : 内部サーバーエラー。'
components:
  schemas:
    TextToAudioRequest:
      description: テキストから音声への変換のリクエストボディ。`message_id` または `text` のいずれかを指定してください。
      properties:
        message_id:
          description: >-
            回答を音声化するメッセージの ID です。両方が指定された場合、`text` よりも優先されます。メッセージ ID は
            [会話履歴メッセージ一覧を取得](/ja/api-reference/conversations/list-conversation-messages)
            から取得します。
          format: uuid
          type: string
        streaming:
          description: >-
            後方互換性のために受け付けられますが、効果はありません。音声がストリーミングされるかどうかは、設定された TTS
            プロバイダーの出力によって決まり、このフィールドでは制御されません。
          type: boolean
        text:
          description: 音声に合成するテキストです。
          type: string
        user:
          description: >-
            エンドユーザーの識別子。アプリ側で定義し、アプリ内で一意にします。[エンドユーザーの識別](/ja/api-reference/guides/end-user-identity)
            を参照してください。
          type: string
        voice:
          description: >-
            テキスト読み上げに使用する音声。利用可能な音声は、このアプリに設定された TTS
            プロバイダーによって異なります。デフォルトには[アプリケーションのパラメータ情報を取得](/ja/api-reference/applications/get-app-parameters)
            → `text_to_speech.voice` の `voice` 値を使用してください。
          type: string
      type: object
  securitySchemes:
    ApiKeyAuth:
      bearerFormat: API_KEY
      description: >-
        すべてのリクエストは API キーで認証します：`Authorization: Bearer
        {API_KEY}`。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API
        キーを使用します（[Dify API クイックスタート](/ja/api-reference/guides/get-started)）。


        キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーが欠落または無効なリクエストは HTTP
        `401`（`unauthorized`）で失敗します。
      scheme: bearer
      type: http

````