通过插槽进行实时转录,随着说话者说话时返回部分结果,语音活动检测会标记每一句话。
EmpirioLabs exposes the standard WEBSOCKET /v1/realtime endpoint and returns partial and final transcripts as the speaker talks.
也称为 StepAudio ASR Stream, StepFun StepAudio 2.5 ASR Stream
stepaudio-2-5-asr-stream/v1/realtimestepaudio-2.5-asr-streamstepfun/stepaudio-2-5-asr-stream来自 EmpirioLabs 目录的实时按量计费价格。只为实际用量付费,没有月度最低消费。
StepAudio 2.5 ASR Stream 通过 wss://api.empiriolabs.ai/v1/realtime?model=stepaudio-2-5-asr-stream 的 WebSocket 转写实时音频流,而不是通过 HTTP 端点。使用模型 id stepaudio-2-5-asr-stream 连接,并在握手时将 EmpirioLabs API 密钥作为 Authorization: Bearer 请求头发送。追加 base64 编码的 16 位 PCM 音频,说话过程中即可读取转写事件。 浏览器无法为 WebSocket 设置请求头,请从你的服务器发起该连接,再通过你自己的 socket 把音频转发给浏览器。 在EmpirioLabs 控制台获取 API 密钥。
import asyncio, json, os, websockets
async def main():
async with websockets.connect(
"wss://api.empiriolabs.ai/v1/realtime?model=stepaudio-2-5-asr-stream",
additional_headers=[
("Authorization", f"Bearer {os.environ['EMPIRIOLABS_API_KEY']}"),
],
max_size=None,
) as ws:
print(json.loads(await ws.recv())["type"]) # session.created
import base64
# 16-bit PCM microphone audio, base64 encoded, in small chunks.
for chunk in read_microphone_chunks():
await ws.send(json.dumps({
"type": "input_audio_buffer.append",
"audio": base64.b64encode(chunk).decode(),
}))
await ws.send(json.dumps({"type": "input_audio_buffer.commit"}))
async for raw in ws:
event = json.loads(raw)
if event["type"].endswith("input_audio_transcription.delta"):
# "text" is settled transcript; "stash" is still in progress.
if event.get("text"):
print(event["text"], end="", flush=True)
asyncio.run(main())EmpirioLabs 上 StepAudio 2.5 ASR Stream API 支持的请求参数。省略字段时使用默认值。
| 参数 | 类型 | 默认值 | 范围 / 值 | 描述 |
|---|---|---|---|---|
| input_audio_format | enum | pcm16 | pcm16 | 你附加到输入缓冲区的音频编码:base64 16位 PCM。 |
| language | enum | zh | en, zh, fr, es | 识别语言。 |
Live transcription over a WebSocket at wss://api.empiriolabs.ai/v1/realtime?model=stepaudio-2-5-asr-stream, authenticated with the ordinary Authorization Bearer header. Stream 16 kHz pcm16 audio up with input_audio_buffer.append and read partial results back as the speaker is still talking, with server-side voice activity detection marking where each sentence ends. Use this for live captions and voice input; for a finished recording, StepAudio 2.5 ASR returns the whole transcript in one call. Billing follows the duration of audio you stream, settled when the session closes.
在 EmpirioLabs,StepAudio 2.5 ASR Stream 按量计费:转录 $0.18 每小时音频。本页的实时价格表始终与 API 的实际计费一致。
StepAudio 2.5 ASR Stream 通过 api.empiriolabs.ai 上的 WEBSOCKET /v1/realtime 提供,使用标准的 Bearer 令牌认证。
打开EmpirioLabs Playground并点击 Start session,即可在浏览器中试用。StepAudio 2.5 ASR Stream 运行在 WebSocket 上,而不是一次请求一次响应,因此接入时请从实时语音快速入门开始。用 EmpirioLabs API 密钥和模型 id stepaudio-2-5-asr-stream 从你的服务器连接,然后双向流式传输音频。
创建 EmpirioLabs 账户,然后在控制台的 API Keys生成密钥。计费使用按量付费的额度,只为实际发出的请求付费。