API 參考
音頻
使用語音生成、音頻轉寫和音頻翻譯接口。
音頻接口包含語音生成、音頻轉寫和音頻翻譯。語音生成使用 JSON 請求體;轉寫和翻譯通常使用 multipart 表單上傳音頻文件。
端點
| 方法 | 路徑 | 說明 |
|---|---|---|
POST | /v1/audio/speech | 文本轉語音 |
POST | /v1/audio/transcriptions | 音頻轉寫 |
POST | /v1/audio/translations | 音頻翻譯 |
請求參數
| 字段 | 類型 | 適用接口 | 說明 |
|---|---|---|---|
model | string | 全部 | 音頻模型 ID,必填 |
input | string | speech | 要轉換為語音的文本 |
voice | string | speech | 聲音 ID |
instructions | string | speech | 語音風格或額外指令 |
response_format | string | 全部 | 返回格式。轉寫/翻譯默認 json |
speed | number | speech | 語速 |
stream_format | string | speech | 設置為 sse 時按模型支持啟用流式 |
metadata | object | speech | 透傳元數據 |
file | file | transcriptions/translations | multipart 表單中的音頻文件,必填 |
language | any | 擴展 | 部分渠道支持的語言參數 |
語音生成
curl https://api.tensoraxis.com/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-d '{
"model": "tts-1",
"voice": "alloy",
"input": "你好,歡迎使用 TENSORAXIS。",
"response_format": "mp3"
}' \
--output speech.mp3音頻轉寫
curl https://api.tensoraxis.com/v1/audio/transcriptions \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-F model="whisper-1" \
-F file="@audio.mp3" \
-F response_format="json"音頻翻譯
curl https://api.tensoraxis.com/v1/audio/translations \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-F model="whisper-1" \
-F file="@audio.mp3" \
-F response_format="json"響應結構
轉寫和翻譯的 JSON 響應通常包含 text:
{
"text": "Transcribed text..."
}語音生成會直接返回音頻二進制內容,響應 Content-Type 取決於 response_format 和上游模型。