跳到主要內容

音訊

包含語音轉文字、語音翻譯與文字轉語音(TTS)三組 API:轉寫/翻譯以 multipart/form-data 上傳檔案,TTS 接收 JSON 並回傳二進位音訊。

語音轉文字​

POST /v1/audio/transcriptions
curl 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)​

欄位類型必填說明
filefile是音訊檔案(mp3/wav/m4a/webm 等,≤25MB)
modelstring是whisper-1、gpt-4o-transcribe、gpt-4o-mini-transcribe 等
languagestring否ISO-639-1 語言代碼(如 zh),可提升辨識準確度
promptstring否引導文字,協助拼寫專有名詞
response_formatstring否json(預設)/ text / srt / verbose_json / vtt
temperaturenumber否取樣溫度

回應​

{ "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/speech
curl 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

請求主體參數​

參數類型必填說明
modelstring是tts-1、tts-1-hd、gpt-4o-mini-tts 等
inputstring是待合成的文字,最長 4096 字元
voicestring是alloy / echo / fable / onyx / nova / shimmer 等
response_formatstring否mp3(預設)/ opus / aac / flac / wav / pcm
speednumber否0.25–4.0,預設 1.0

回應​

成功時直接回傳音訊二進位串流(依 response_format 編碼),請存成檔案,不要當成 JSON 解析。

警告

在瀏覽器測試台使用語音轉文字/翻譯時,請切換到表單模式上傳檔案。TTS 回應是二進位串流——測試台會為它內嵌音訊播放器,但仍建議以 cURL/SDK 驗證。