BazaarLinkBazaarLink
登入
文件API 参考SDK 参考Agent 应用AI Skills
章节导航

语音转文字(转录)指南

语音转文字(转录)指南

POST /v1/audio/transcriptions 与 OpenAI-compatible 接口兼容:通过 multipart/form-data 上传音频,或通过 JSON 发送 base64 格式的 input_audio,返回文字。模型包括 elevenlabs/scribe-v2 和 elevenlabs/scribe-v2-medical。最新列表见 GET /v1/models?output_modalities=transcription。 GET /v1/models 默认只返回文本模型,请加上 ?output_modalities=transcription(或 all)才会列出转录模型。

POST/v1/audio/transcriptions

参数

参数类型必填说明
modelstring是转录模型 ID,例如 elevenlabs/scribe-v2。
filefile是音频文件(multipart)。支持 wav、mp3、mp4、m4a、ogg、flac、webm、aac,最大 25 MiB。JSON 客户端可改用 input_audio: {data: base64, format}。
response_formatstring否json(默认)返回 {text};verbose_json 还包含语言、时长以及 segments/words。
languagestring否可选语言提示,例如 en 或 zh。留空则自动识别。
promptstring否可选上下文文字,有助于识别人名和术语;并非所有模型都会应用。
timestamp_granularities[]string[]否word 和/或 segment。仅在 response_format=verbose_json 时生效,其他格式会忽略。 目前尚未返回逐词(word)时间戳,会返回 segments。

输出格式

response_format 仅支持 json 或 verbose_json(不支持 text、srt、vtt)。不支持 stream。音频时长按模型限制,默认 60 秒;超过时在处理前返回 413 audio_too_long,且不收费。较长的录音请分段。

计费

转录按音频秒数计费。每秒价格见 /models 中的模型页,以及 GET /v1/models 中的 pricing.second;每分钟价格为其 60 倍。响应的 usage 显示计费秒数,usage.cost 显示扣费金额。

示例

curl https://api.bazaarlink.ai/v1/audio/transcriptions \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY" \
  -F model="elevenlabs/scribe-v2" \
  -F file=@audio.mp3 \
  -F response_format=verbose_json \
  -F "timestamp_granularities[]=word"

常见错误

状态码原因与处理
400请求无效:缺少 model 或 file、音频为空、response_format 不是 json/verbose_json、发送 stream=true(unsupported_parameter),或 timestamp_granularities 不是 word/segment。
401API 密钥缺失或无效。
402余额不足,请充值后重试。
413audio_too_large:解码后音频超过 25 MiB。audio_too_long:音频超过按模型设置的时长限制(默认 60 秒),处理前即拒绝且不收费。请压缩或分段。
429达到速率限制,请按 Retry-After 响应头等待后重试。
502模型服务暂时不可用,或音频传输中断。请重试;失败的请求不收费。

完整参数参考: 语音转写

语音转写

使用 multipart/form-data 的 model、file,或 JSON 的 model、input_audio:{data,format}(原始 base64)。格式:wav、mp3、mp4、m4a、ogg、flac、webm、aac。解码音频上限 25 MiB;请求正文上限 50 MiB,允许 base64。audio.transcription_max_seconds_by_model 设置各模型上限;未设置时依次使用 audio.transcription_max_seconds 和默认 60 秒。超过时在处理前返回 413 audio_too_long,且不收费。response_format 仅支持 json、verbose_json;timestamp_granularities 的 word、segment 需要 verbose_json。stream 不支持(400 unsupported_parameter);音频过大:413 audio_too_large。provider 被忽略。按数据库模型價格以 usage.seconds 或输入/输出 token 计费;每分钟价格为每秒的 60 倍。usage.cost 是客户的 USD 费用。

POST/v1/audio/transcriptions
curl https://api.bazaarlink.ai/v1/audio/transcriptions \
  -H "$BAZAARLINK_AUTH_HEADER" \
  -F model="<transcription-model-id>" \
  -F file=@audio.wav \
  -F response_format=json

curl https://api.bazaarlink.ai/v1/audio/transcriptions \
  -H "$BAZAARLINK_AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{"model":"<transcription-model-id>","input_audio":{"data":"<raw-base64-audio>","format":"wav"},"response_format":"verbose_json","timestamp_granularities":["word","segment"]}'
客服
您好!有什么可以协助?
请留下消息,我们会尽快回复。
语音转文字(转录)指南 | BazaarLink