音声モデル
音声生成
CometAPI の POST /v1/audio/speech を使用して、選択した text-to-speech model と出力形式でテキストを音声に変換します。
POST
Python
このエンドポイントを使用すると、OpenAI 互換の音声 API を通じてテキストを音声ファイルに変換できます。ナレーション、短い音声プロンプト、読み上げ機能、その他、アプリにすでにテキストがあり音声出力が必要なワークフローに適しています。
First request
まずはmodel、input、voice の 3 つのフィールドから始めます。speed や出力形式を調整する前に、最初のリクエストは短くして、認証、音声形式、ファイル処理を確認できるようにしてください。
Read the response
レスポンスは JSON ではなくバイナリ音声です。SDK の例では、レスポンスをoutput.mp3 のようなファイルに書き込みます。直接 HTTP クライアントを使う場合は、レスポンスボディを保存し、要求した response_format に合わせてファイル拡張子を設定してください。
Next steps
承認
Bearer token authentication. Use your CometAPI key.
ボディ
application/json
The TTS model to use. Choose a current speech model from the Models page.
The text to generate audio for. Maximum length is 4096 characters.
Maximum string length:
4096The voice to use for speech synthesis.
利用可能なオプション:
alloy, ash, ballad, coral, echo, fable, onyx, nova, sage, shimmer The audio output format.
利用可能なオプション:
mp3, opus, aac, flac, wav, pcm The speed of the generated audio. Select a value between 0.25 and 4.0.
必須範囲:
0.25 <= x <= 4レスポンス
200 - audio/mpeg
The audio file content.
The response is of type file.