音訊
包含語音轉文字、語音翻譯與文字轉語音(TTS)三組 API:轉寫/翻譯以 multipart/form-data 上傳檔案,TTS 接收 JSON 並回傳二進位音訊。
語音 轉文字
POST /v1/audio/transcriptionscurl https://test.kailin.com.cn/v1/audio/transcriptions \
-H "Authorization: Bearer sk-your-token" \
-F "file=@/path/to/audio.mp3" \
-F "model=whisper-1" \
-F "language=zh"
欄位(form-data)
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
file | file | 是 | 音訊檔案(mp3/wav/m4a/webm 等,≤25MB) |
model | string | 是 | whisper-1、gpt-4o-transcribe、gpt-4o-mini-transcribe 等 |
language | string | 否 | ISO-639-1 語言代碼(如 zh),可提升辨識準確度 |
prompt | string | 否 | 引導文字,協助拼寫專有名詞 |
response_format | string | 否 | json(預設)/ text / srt / verbose_json / vtt |
temperature | number | 否 | 取樣溫度 |
回應
{ "text": "This is the transcribed text." }
verbose_json 格式會額外回傳分段與時間戳記(segments / duration)。
語音翻譯
POST /v1/audio/translations將音訊內容翻譯成英文,欄位與語音轉文字相同(無 language 參數):
curl https://test.kailin.com.cn/v1/audio/translations \
-H "Authorization: Bearer sk-your-token" \
-F "file=@/path/to/audio.mp3" \
-F "model=whisper-1"
{ "text": "This is the English translation of the audio." }
文字轉語音
POST /v1/audio/speechcurl https://test.kailin.com.cn/v1/audio/speech \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-token" \
-d '{
"model": "tts-1",
"voice": "alloy",
"input": "Welcome to AI Station."
}' \
--output speech.mp3
請求主體參數
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
model | string | 是 | tts-1、tts-1-hd、gpt-4o-mini-tts 等 |
input | string | 是 | 待合成的文字,最長 4096 字元 |
voice | string | 是 | alloy / echo / fable / onyx / nova / shimmer 等 |
response_format | string | 否 | mp3(預設)/ opus / aac / flac / wav / pcm |
speed | number | 否 | 0.25–4.0,預設 1.0 |
回應
成功時直接回傳音訊二進位串流(依 response_format 編碼),請存成檔案,不要當成 JSON 解析。
警告
在瀏覽器測試台使用語音轉文字/翻譯時,請切換到表單模式上傳檔案。TTS 回應是二進位串流——測試台會為它內嵌音訊播放器,但仍建議以 cURL/SDK 驗證。