logo
開發者文件
搜尋
文本轉語音

文本轉語音

將 Agent 輸出的文本轉換為語音播放。

請求方法

POST

請求 URL

https://api-${endpoint}.gptbots.ai/v1/text-to-audio

請求驗證

請參考 概覽 中的 API Reference。

請求

請求範例

curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/text-to-audio' \ -H 'Authorization: Bearer ${API Key}' \ -H 'Content-Type: application/json' \ -d '{ "id": "消息 ID" }'
                      
                      curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/text-to-audio' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
    "id": "消息 ID"
}'

                    
此代碼塊在浮窗中顯示

請求標頭

欄位 類型 描述
Authorization Bearer ${API Key} 請使用 Authorization: Bearer ${API Key} 來進行驗證。您可以從 API Key 頁面取得 API Key。
Content-Type application/json 資料類型,設為 application/json。

請求內容

欄位 類型 必填 描述
id string 消息 ID。

回應

回應範例

位元組流,串流返回。
                      
                      位元組流,串流返回。

                    
此代碼塊在浮窗中顯示

成功回應

欄位 類型 描述
Byte[] 位元組流(音訊串流資料)。

失敗回應

欄位 類型 描述
code int 錯誤代碼
message string 錯誤詳情

錯誤代碼

錯誤代碼 錯誤訊息
40000 無效參數
40107 憑證已過期
40127 開發者驗證失敗
40325 無效的檔案類型,僅支援 'm4a'、'mp3'、'webm'、'mp4'、'mpga'、'wav'、'mpeg'
50000 內部伺服器錯誤
40113 未經授權訪問 Agent
20059 Agent 已刪除
40371 語音內容為空
40379 餘額不足