语音转文字(STT)
API Configuration
After saving, the Try It panel below sends real requests with this key.
Base: api.xrtoken.ai
将音频文件转录为文字。请求使用 multipart/form-data 格式,必须包含 file(16k/单声道/16bit wav)和 model(如 doubao-asr)字段。
音频格式要求(严格校验):
- 容器:WAV (RIFF/WAVE)
- 编码:PCM (s16le)
- 采样率:16000 Hz
- 声道:单声道 (mono)
- 位深度:16 bit
不符合上述格式的音频将在上传时被拒绝并返回 400 错误(不会调用上游识别服务,不产生计费)。
响应格式:成功时返回 Volcengine 格式的 JSON 响应,包含以下字段:
result.text— 识别后的文字内容audio_info.duration— 识别的音频时长(毫秒),用于结算request_id— 网关请求 ID(tr-req-前缀)
计费方式:按音频时长计费,结算使用 audio_info.duration(毫秒)计算实际费用。
Authorization
BearerAuth AuthorizationBearer <token>
API 密钥认证(OpenAI 格式)。在 Authorization 请求头中传入:
Authorization: Bearer tr-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
In: header
Request Body
multipart/form-data
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
curl -X post "https://api.xrtoken.net/v1/audio/transcriptions" \ -F model="doubao-asr" \ -F file="string"{
"audio_info": {
"duration": 1200
},
"request_id": "tr-req-a1b2c3d4e5f6",
"result": {
"text": "你好,欢迎使用 XRToken。"
}
}{
"error": "model field is required",
"type": "invalid_request_error"
}{
"error": "invalid or missing API key",
"type": "auth_error"
}{
"error": "insufficient balance -- please top up or upgrade your plan",
"type": "billing_error"
}{
"error": "rate limit exceeded",
"type": "rate_limit_error"
}{
"error": "upstream provider error",
"type": "server_error"
}