通过插槽进行实时转录,随着说话者说话时返回部分结果,语音活动检测会标记每一句话。
EmpirioLabs暴露标准/v1/audio/transcriptions终点,并以正常转录响应格式返回最终转录本。
也称为 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 | Encoding of the audio you append to the input buffer: base64 16-bit PCM. |
| language | string | - | - | Optional language hint. Omit to let the model detect it. |
通过 wss@api.empiriolabs.ai/v1/realtime?model=stepaudio-2-5-asr-stream 的 WebSocket 进行实时转录,并用普通授权承载人头进行认证。将 16 kHz pcm16 音频上传并带 input_audio_buffer.append,并在说话者还在说话时读取部分结果,服务器端的语音活动检测会标记每句话的结束位置。用于实时字幕和语音输入;对于完成的录音,POST /v1/audio/transcriptions 一次通话返回整个文字记录。计费按您流媒体音频的时长计费,会话结束时确定。
在 EmpirioLabs,StepAudio 2.5 ASR Stream 按量计费:转录 $0.18 每小时音频。本页的实时价格表始终与 API 的实际计费一致。
StepAudio 2.5 ASR Stream 通过 api.empiriolabs.ai 上的 WEBSOCKET /v1/realtime 提供,使用标准的 Bearer 令牌认证。
StepAudio 2.5 ASR Stream 运行在 WebSocket 上,而不是一次请求一次响应,请从实时语音快速入门开始。用 EmpirioLabs API 密钥和模型 id stepaudio-2-5-asr-stream 从你的服务器连接,然后双向流式传输音频。
创建 EmpirioLabs 账户,然后在控制台的 API Keys生成密钥。计费使用按量付费的额度,只为实际发出的请求付费。