外观
语音转文字
POST
https://vip.zen-ai.top/v1/audio/transcriptions将音频转写为文字,请求使用 multipart/form-data 上传文件。支持 mp3、mp4、mpeg、mpga、m4a、wav、webm 等格式,单个文件不超过 25 MB。
请求体(multipart/form-data)
filefile必填音频文件。
modelstring必填模型名称,如 gpt-4o-mini-transcribe、gpt-4o-transcribe、whisper-1。
languagestring音频语言(ISO-639-1 代码,如 zh、en),指定后可提升准确率和速度。
promptstring提示文本,可包含专有名词、人名或上文,帮助模型正确识别。
response_formatstring默认 json输出格式。gpt-4o-transcribe 系列仅支持 json 与 text;字幕格式请使用 whisper-1。
可选值
jsontextsrtverbose_jsonvtttemperaturenumber默认 0采样温度 0–1。
timestamp_granularities[]array时间戳粒度 word / segment,仅 whisper-1 且 response_format 为 verbose_json 时可用。
响应
textstring转写结果。
usageobject用量信息(gpt-4o-transcribe 系列)。
response_format 为 text、srt、vtt 时直接返回纯文本。
请求示例
bash
curl https://vip.zen-ai.top/v1/audio/transcriptions \
-H "Authorization: Bearer $VIP_API_KEY" \
-F "[email protected]" \
-F "model=gpt-4o-mini-transcribe" \
-F "language=zh"python
from openai import OpenAI
client = OpenAI(base_url="https://vip.zen-ai.top/v1", api_key="sk-xxxxxxxx")
with open("meeting.mp3", "rb") as f:
result = client.audio.transcriptions.create(
model="gpt-4o-mini-transcribe",
file=f,
language="zh",
)
print(result.text)python
with open("video.mp4", "rb") as f:
srt = client.audio.transcriptions.create(
model="whisper-1",
file=f,
response_format="srt",
)
open("video.srt", "w", encoding="utf-8").write(srt)响应示例
json
{
"text": "大家好,今天的会议主要讨论下个季度的产品规划。",
"usage": {
"type": "tokens",
"input_tokens": 142,
"output_tokens": 18,
"total_tokens": 160
}
}