Audio API
语音转文字
转写音频,支持时间戳、语言检测和说话人分离,提供多种输出格式。
POSThttps://api.oxyy.ai/v1/audio/transcriptions使用源语言转写
POSThttps://api.oxyy.ai/v1/audio/translations转写为英文
参数
| 参数 | 类型 | 必填 | 描述 |
|---|---|---|---|
| model | string | 必填 | 语音转文本 model id。 |
| 文件 | 文件 | Required* | 音频,格式为 multipart/form-data。支持的容器:mp3, mp4, mpeg, mpga, m4a, wav, webm, ogg, flac。 |
| file_url | string | Required* | 用于替代上传的公开获取 URL。最大 25 MB;私有地址和回环地址将被拒绝。 |
| file_base64 | string | Required* | Base64 音频,带或不带 data: 前缀。 |
| response_format | string | 可选 | 以下之一:jsontextverbose_jsonsrtvttdiarized_json 默认 json |
| language | string | 可选 | ISO-639-1 代码(en、ja、bn)。省略则自动检测。 |
| prompt | string | 可选 | 词汇或风格提示 — 姓名、专业术语、预期拼写。 |
| temperature | number | 可选 | 采样温度,0–1。 |
| timestamp_granularities | array | 可选 | 需要 verbose_json。 以下之一:wordsegment |
| diarize | boolean | 可选 | 在支持该功能的模型上标记发言者。 |
| num_speakers | integer | 可选 | 说话人分离的提示。 |
*恰好属于以下之一:
file, file_url 或 file_base64 是必填项。 /v1/audio/translations 接受相同的参数并返回英文文本。并非所有转录模型都支持翻译;不支持的会返回 400 明确说明。代码示例
import os from openai import OpenAI client = OpenAI( api_key=os.environ["OXYY_API_KEY"], base_url="https://api.oxyy.ai/v1" ) # Supported containers: mp3, mp4, mpeg, mpga, m4a, wav, webm, ogg, flac with open("interview.mp3", "rb") as audio_file: response = client.audio.transcriptions.create( model="scribe_v2", file=audio_file, response_format="verbose_json", timestamp_granularities=["segment"], language="en", ) print(response.text) for seg in response.segments: print(f"{seg.start:.1f}s-{seg.end:.1f}s: {seg.text}")
import fs from 'fs'; import OpenAI from 'openai'; const client = new OpenAI({ apiKey: process.env.OXYY_API_KEY, baseURL: 'https://api.oxyy.ai/v1' }); const response = await client.audio.transcriptions.create({ model: 'scribe_v2', file: fs.createReadStream('interview.mp3'), response_format: 'verbose_json', language: 'en', }); console.log(response.text);
# multipart upload curl https://api.oxyy.ai/v1/audio/transcriptions \ -H "Authorization: Bearer $OXYY_API_KEY" \ -F "model=scribe_v2" \ -F "file=@interview.mp3" \ -F "response_format=verbose_json" \ -F "language=en" # …or JSON with a hosted URL instead of an upload curl https://api.oxyy.ai/v1/audio/transcriptions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $OXYY_API_KEY" \ -d '{"model": "scribe_v2", "file_url": "https://example.com/interview.mp3"}'
# Same inputs as /transcriptions; the transcript comes back in English. curl https://api.oxyy.ai/v1/audio/translations \ -H "Authorization: Bearer $OXYY_API_KEY" \ -F "model=whisper-large-v3-turbo" \ -F "file=@bengali-interview.mp3" \ -F "response_format=json"
响应示例 (verbose_json)
响应
{
"task": "transcribe",
"language": "en",
"duration": 5.42,
"text": "Hello, this is a transcription test.",
"segments": [
{ "id": 0, "start": 0.0, "end": 2.1, "text": "Hello, this is" },
{ "id": 1, "start": 2.1, "end": 5.42, "text": "a transcription test." }
]
}verbose_json 将按原样向提供商请求。唯一的例外是文本形状的格式: text, srt 与 vtt 此处由定时结果渲染,因此适用于所有供应商。
可用模型
17 models
模型
Model ID
