API 参考OpenAI 兼容
Audio
OpenAI Whisper API - 通过 UniterRouter 实现语音转文字。GPT-4 级别精度,支持多语言和多种音频格式。
Audio
使用最先进的语音识别模型将音频文件转录为文字。
端点
POST https://api.uniterouter.ai/v1/audio/transcriptions请求
此端点接受 multipart/form-data,包含以下字段:
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
file | file | 是 | 要转录的音频文件 |
model | string | 是 | 模型 ID(例如 whisper-1) |
language | string | 否 | 语言代码(ISO 639-1) |
prompt | string | 否 | 用于指导转录的可选上下文 |
response_format | string | 否 | json、text、srt、vtt、verbose_json |
temperature | number | 否 | 采样温度(0-1) |
支持的格式
| 格式 | 扩展名 |
|---|---|
| MP3 | .mp3 |
| MP4 | .mp4、.m4a |
| WAV | .wav |
| WebM | .webm |
| FLAC | .flac |
| OGG | .ogg |
文件大小限制:最大文件大小为 25 MB。对于更大的文件,请将其分割成多个片段。
支持的模型
| 模型 | 提供商 | 语言 | 备注 |
|---|---|---|---|
whisper-1 | OpenAI | 50+ | 最佳准确度 |
whisper-large-v3 | Groq | 50+ | 快速推理 |
请求示例
curl https://api.uniterouter.ai/v1/audio/transcriptions \
-H "Authorization: Bearer $UNITEROUTER_API_KEY" \
-F file="@audio.mp3" \
-F model="whisper-1"from openai import OpenAI
client = OpenAI(
base_url="https://api.uniterouter.ai/v1",
api_key="your_api_key",
)
with open("audio.mp3", "rb") as audio_file:
response = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file
)
print(response.text)import OpenAI from "openai";
import fs from "fs";
const client = new OpenAI({
baseURL: "https://api.uniterouter.ai/v1",
apiKey: process.env.UNITEROUTER_API_KEY,
});
const response = await client.audio.transcriptions.create({
model: "whisper-1",
file: fs.createReadStream("audio.mp3"),
});
console.log(response.text);响应
JSON 格式(默认)
{
"text": "你好,这是音频文件的示例转录。"
}详细 JSON 格式
{
"task": "transcribe",
"language": "chinese",
"duration": 12.5,
"text": "你好,这是示例转录。",
"segments": [
{
"id": 0,
"start": 0.0,
"end": 2.5,
"text": "你好,"
}
]
}语言支持
Whisper 支持 50+ 种语言。指定语言可获得更好的准确度:
response = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file,
language="zh" # 中文
)常用语言代码:en、zh、ja、ko、es、fr、de
How is this guide?