音频
包含语音转写、语音翻译与文本转语音(TTS)三组接口,转写/翻译为 multipart/form-data 上传,TTS 为 JSON 请求返回二进制音频。
语音转写
POST /v1/audio/transcriptionscurl 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)
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
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": "这是转写出来的文本内容。" }
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/speechcurl 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
请求体参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
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 验证。