音频转写
将音频转换为文本,适合会议、访谈、语音消息和媒体内容处理。
操作流程
POST /v1/audio/transcriptions
Endpoint
moss-transcribe
模型
创建 API Key
进入 API Key 管理平台,创建 API Key,并保存为环境变量。不要把 API Key 写进客户端代码或提交到仓库。
示例 export MOSS_API_KEY="<your-api-key>"准备请求输入
用
model指定moss-transcribe,给出待转写音频(file、file_id、url或audio_url)。file / file_id / url / audio_url:待转写音频 model:moss-transcribe response_format:json / text 等
request.json { "model": "moss-transcribe", "file_id": "<file_id>", "response_format": "json" }发起第一次请求
向
POST /v1/audio/transcriptions发起请求,同步请求直接返回转写结果。curl https://api.mosi.cn/v1/audio/transcriptions \ -H "Authorization: Bearer $MOSS_API_KEY" \ -H "Content-Type: application/json" \ -d @request.json获取结果
同步请求直接返回转写结果。如果传了
async=true,接口会先返回task_id,再用它查询转写任务。查询转写任务 curl https://api.mosi.cn/v1/audio/transcriptions/$TASK_ID \ -H "Authorization: Bearer $MOSS_API_KEY"验证成功
成功标志:拿到转写文本。