跳到主要内容

音频

包含语音转写、语音翻译与文本转语音(TTS)三组接口,转写/翻译为 multipart/form-data 上传,TTS 为 JSON 请求返回二进制音频。

语音转写​

POST /v1/audio/transcriptions
curl https://test.kailin.com.cn/v1/audio/transcriptions \
-H "Authorization: Bearer sk-你的令牌" \
-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": "这是转写出来的文本内容。" }

verbose_json 格式额外返回分段与时间戳(segments / duration)。

语音翻译​

POST /v1/audio/translations

将音频内容翻译为英文,字段与转写一致(无 language 参数):

curl https://test.kailin.com.cn/v1/audio/translations \
-H "Authorization: Bearer sk-你的令牌" \
-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-你的令牌" \
-d '{
"model": "tts-1",
"voice": "alloy",
"input": "你好,欢迎来到 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 验证。