音訊模型
建立語音
使用 CometAPI POST /v1/audio/speech,透過所選的文字轉語音模型與輸出格式將文字轉換為音訊。
POST
Python
使用此端點可透過與 OpenAI 相容的音訊 API,將文字轉換為音訊檔案。它適合用於旁白、簡短語音提示、朗讀功能,以及其他你的應用程式已經有文字內容且需要語音輸出的工作流程。
First request
先從三個欄位開始:model、input 和 voice。請讓第一次請求保持簡短,以便在調整速度或輸出格式之前,先驗證驗證資訊、音訊格式與檔案處理。
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.