语音转文字
curl --request POST \
--url https://kaienapi.com/v1/audio/transcriptions \
--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/transcriptions"
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/transcriptions', 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/transcriptions"
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 Transcriptions 兼容接口,将音频转成原语言文本。
请求格式
使用 multipart/form-data 上传音频文件。必须包含 file 和 model。
参数要点
language:音频语言,优先填zh、en这类两位代码;不传时自动识别。prompt:填写人名、品牌名、产品名或上下文,减少术语误写。response_format:json供程序读取,text返回纯文本,srt/vtt生成字幕,verbose_json返回分段和时间信息。
接入顺序
先用 10 到 30 秒音频确认模型、格式和语言识别,再接入长音频切片、批量转写和结果保存。
错误定位
- 文件无法识别:检查音频格式、文件大小和 Content-Type。
- 专有名词错误:把术语写进
prompt。 - 字幕时间不准:使用
verbose_json查看分段,再决定是否后处理。
POST
/
v1
/
audio
/
transcriptions
语音转文字
curl --request POST \
--url https://kaienapi.com/v1/audio/transcriptions \
--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/transcriptions"
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/transcriptions', 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/transcriptions"
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.