语音合成

声音克隆

对口型视频

其他

语音转文字

提交音频 URL,将语音识别为文字,按分钟消耗 API 积分

语音转文字接口

接口地址

POST /api/open/speech-to-text

请求头

Content-Type: application/json
Authorization: Bearer YOUR_API_TOKEN  // 可选,也可在请求体中传 token

请求参数

{
  "audio_url": string,           // 必填,音频文件公网可访问 URL
  "language": string,            // 可选,默认 "auto"。可选: auto, zh, en, ja, ko, fr, de, es, ar
  "ignore_timestamps": boolean,  // 可选,默认 false。为 true 时不返回分段时间戳
  "file_name": string,           // 可选,用于识别格式,如 "audio.mp3"。不传则按 URL 或默认 "audio.mp3"
  "token": string                // 可选,若未在 Authorization 中提供则必填
}

返回数据

// 成功响应 - 200
{
  "text": string,              // 识别出的全文
  "duration": number,          // 音频时长(秒)
  "segments": array,           // 分段详情(含时间戳,若 ignore_timestamps 为 true 可能为空)
  "credits_used": number,      // 本次消耗的 API 积分(约 10 积分/分钟)
  "quota_remaining": number    // 剩余 API 积分
}

// 错误响应
{
  "error": string,
  "remaining_quota"?: number,  // 402 时返回
  "required_quota"?: number
}

CURL 示例

curl -X POST /api/open/speech-to-text \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{
    "audio_url": "https://example.com/audio.mp3",
    "language": "auto",
    "ignore_timestamps": false
  }'

在线调试

需为公网可访问的音频地址,支持 mp3、wav、m4a、ogg、webm、flac、aac、wma,单文件最大 50MB

状态码说明

状态码说明:
200 OK                  - 请求成功
400 Bad Request         - 请求参数错误
401 Unauthorized        - API Token 无效
403 Forbidden          - 禁止访问
404 Not Found          - 资源不存在
413 Payload Too Large  - 上传文件过大
429 Too Many Requests  - 请求频率超限/积分不足
500 Server Error       - 服务器内部错误

错误响应格式:
{
  "error": string,      // 错误信息
  "details": string,    // 详细错误信息(可选)
  "code": string       // 错误代码(可选)
}