Create a Transcription
Transcribes audio into the input language. The audio data is sent in the request body as multipart/form-data.
端点:POST /v1/audio/transcriptions
Request Body
file (file, required)
待转录的音频文件。支持 mp3、mp4、mpeg、mpga、m4a、wav、webm 等常见格式。
model (string, required)
用于语音识别的模型,详见 模型广场。
language (string, optional)
音频中的语种,如 zh(中文)、en(英文)。设置后可提升识别准确率。
response_format (string)
响应格式。可选值:json | text | srt | verbose_json | vtt。默认 json。
prompt (string, optional)
可选的提示词,用于引导模型风格(如专业术语、口音偏好等)。
temperature (number)
采样温度,范围 0.0 ~ 1.0。默认 0。
代码示例
cURL
curl --request POST \
--url https://khb.net.cn/v1/audio/transcriptions \
--header 'Authorization: Bearer YOUR_API_KEY' \
--form file=@audio.mp3 \
--form model=FunAudioLLM/SenseVoiceSmall \
--form language=zh \
--form response_format=json
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://khb.net.cn/v1"
)
audio_file = open("audio.mp3", "rb")
transcript = client.audio.transcriptions.create(
model="FunAudioLLM/SenseVoiceSmall",
file=audio_file,
language="zh",
response_format="json"
)
print(transcript.text)
audio_file.close()
Response Body
{
"text": "这是一段测试音频的转录文本内容。"
}
支持的模型
- FunAudioLLM/SenseVoiceSmall – 阿里达摩院多语种语音识别
- 其他 Whisper 兼容模型
最佳实践
- 音频采样率建议 16kHz 以上
- 长音频建议分段(每段 ≤ 10 分钟)
- 明确指定语种可显著提升准确率
