语音翻译
curl --request POST \
--url https://kaienapi.com/v1/audio/translations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=whisper-1 \
--form file='@example-file'import requests
url = "https://kaienapi.com/v1/audio/translations"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "model": "whisper-1" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('model', 'whisper-1');
form.append('file', '<binary>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://kaienapi.com/v1/audio/translations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://kaienapi.com/v1/audio/translations"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nwhisper-1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<binary>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}OpenAI Audio Translations 兼容接口,将非英文语音直接转成英文文本。
请求格式
使用 multipart/form-data 上传音频文件。必须包含 file 和 model,按需要设置 prompt 与 response_format。
与转写接口的区别
/v1/audio/transcriptions 返回原语言文本;/v1/audio/translations 返回英文文本。国际会议、访谈、课程和英文检索分析流程常会用到这个接口。
读取结果
默认返回 JSON。需要纯文本或字幕时设置 response_format。如果要同时保留原文和英文译文,分别调用转写和翻译接口。
POST
/
v1
/
audio
/
translations
语音翻译
curl --request POST \
--url https://kaienapi.com/v1/audio/translations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=whisper-1 \
--form file='@example-file'import requests
url = "https://kaienapi.com/v1/audio/translations"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = { "model": "whisper-1" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('model', 'whisper-1');
form.append('file', '<binary>');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://kaienapi.com/v1/audio/translations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://kaienapi.com/v1/audio/translations"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nwhisper-1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<binary>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}Authorizations
在请求头中传入:Authorization: Bearer sk-...
Body
multipart/form-data
音频转写或翻译请求。使用 multipart/form-data 上传音频文件,并按模型说明选择输出格式、语言提示和其他扩展字段。
要提交的音频文件。常见格式包括 mp3、mp4、mpeg、mpga、m4a、wav、webm;具体限制以模型为准。
音频转写或翻译模型 ID,例如 whisper-1 或兼容模型。
音频语言,使用 ISO-639-1 两位代码,例如 zh、en、ja。不传时由模型自动识别。
提示词。填写专有名词、人名、产品名或上下文,用来减少术语误写。
输出格式。json 供程序读取;text 只返回纯文本;srt/vtt 生成字幕;verbose_json 通常包含更详细的分段或时间信息。
Available options:
json, text, srt, verbose_json, vtt 采样温度。低值输出更确定,高值输出更自由;音频转写一般保持默认。
Response
翻译结果
The response is of type object.