音频转写 API
POST /v1/audio/transcriptions 参考,涵盖文件上传、文件 URL、语言提示、响应格式和计费规则。
把音频转写为文本。支持直接上传文件或传入 URL。
端点
POST https://api.leaper.one/v1/audio/transcriptions模型
| 模型 | 价格 | 说明 |
|---|---|---|
rapid | 0.006 点数/分钟 | 快速转写,支持 file_uri |
whisper-1 | 0.006 点数/分钟 | 高精度转写,支持 prompt |
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| file | file | 与 file_uri 二选一 | 要转写的音频文件,以 multipart 方式上传 |
| file_uri | string | 与 file 二选一 | 要转写的音频文件 URL |
| model | string | 否 | 使用的模型:"rapid" 或 "whisper-1"。默认:"rapid" |
| response_format | string | 否 | 输出格式:"text"、"json"、"verbose_json"、"srt" 或 "vtt"。默认:"json" |
| language | string | 否 | ISO 639-1 语言代码,例如 "en"、"zh"。指定后可提升准确度 |
| prompt | string | 否 | 用于提升转写质量的提示文本 |
| temperature | number | 否 | 0 到 1 之间的采样温度,仅支持 whisper-1 |
请求
上传文件
curl -X POST https://api.leaper.one/v1/audio/transcriptions \
-H "Authorization: Bearer sk-your-api-key" \
-F [email protected] \
-F model=rapid \
-F response_format=json传入 URL(大文件推荐)
curl -X POST https://api.leaper.one/v1/audio/transcriptions \
-H "Authorization: Bearer sk-your-api-key" \
-F file_uri=https://example.com/audio.mp3 \
-F model=rapid \
-F language=zh \
-F response_format=verbose_json使用 file_uri 可以避免通过你的网络上传大文件。服务端会直接拉取音频,rapid 和 whisper-1 都支持这种方式。
使用带 prompt 的 whisper-1
curl -X POST https://api.leaper.one/v1/audio/transcriptions \
-H "Authorization: Bearer sk-your-api-key" \
-F [email protected] \
-F model=whisper-1 \
-F response_format=json \
-F prompt="LEAPERone, GTC, NVIDIA"请求字幕格式
curl -X POST https://api.leaper.one/v1/audio/transcriptions \
-H "Authorization: Bearer sk-your-api-key" \
-F [email protected] \
-F model=whisper-1 \
-F response_format=srt响应
{
"text": "Hello, this is a sample transcription of the audio file."
}使用 verbose_json 时,响应会包含时间戳和分段:
{
"task": "transcribe",
"language": "en",
"duration": 42.5,
"text": "Hello, this is a sample transcription of the audio file.",
"segments": [
{ "start": 0.0, "end": 2.4, "text": "Hello, this is a sample transcription." }
]
}使用 srt 时,响应是纯文本字幕:
1
00:00:00,000 --> 00:00:02,400
Hello, this is a sample transcription.使用 vtt 时,响应采用 WebVTT 格式:
WEBVTT
00:00:00.000 --> 00:00:02.400
Hello, this is a sample transcription.支持的音频格式
mp3、mp4、mpeg、mpga、m4a、wav、webm、opus
直接上传文件的大小上限为 25 MB。使用 file_uri 时没有大小限制。
注意事项
- 按音频时长和上表中的模型单价计费。
- 未指定
model时,默认使用rapid。 - 当前不支持流式转写(
stream=true)。