音频视频理解(听/看后只回文字)
yaoshu-omni 走对话端点 POST /v1/chat/completions:输入文本、图片、音频或视频,输出只有文本。适合听音频或看视频后回答、转写、总结、字幕——音频识别属于它,识别结果是文字。
它不能声明音频输出,不能指定音色,不会回语音。需要语音输出时改用 语音合成(yaoshu-audio)或 实时对话(yaoshu-omni-realtime)。
一、请求示例(音频输入)
bash
curl https://token.yaoshu.cc/v1/chat/completions \
-H "Authorization: Bearer sk-你的密钥" \
-H "Content-Type: application/json" \
-d '{
"model": "yaoshu-omni",
"messages": [{
"role": "user",
"content": [
{"type": "input_audio", "input_audio": {"data": "<音频公网URL或Base64>", "format": "wav"}},
{"type": "text", "text": "这段音频在说什么?"}
]
}],
"modalities": ["text"],
"stream": true
}'二、多模态输入参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
modalities | string[] | 否 | 只使用 ["text"]。本模型只返回文字 |
input_audio.data | string | ✅ | 音频内容:公网 URL 或 Base64 编码 |
input_audio.format | string | ✅ | 音频格式:wav / mp3 等 |
图片/视频输入沿用 对话 Chat 格式 的多模态写法(image_url / video_url)。
三、SDK 接入
python
from openai import OpenAI
client = OpenAI(api_key="sk-你的密钥", base_url="https://token.yaoshu.cc/v1")
transcript = client.chat.completions.create(
model="yaoshu-omni",
messages=[{
"role": "user",
"content": [
{"type": "input_audio", "input_audio": {"data": "https://example.com/speech.wav", "format": "wav"}},
{"type": "text", "text": "逐字转写这段音频"},
],
}],
modalities=["text"], # 只返回文字
stream=True,
)
for chunk in transcript:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")四、限制
- 输出只有文本(无音频输出能力)
- 上下文窗口 1M token(音频按每秒约 7 token 折算,估算预算用)
五、计费
按 token 计量:文本、图片、音频、视频输入与文本输出分别计 token(音频输入按每秒约 7 token 折算,供预算估算参考)。单价以控制台模型价格页为准。
