[Feature] WebSocket streaming audio input for ASR (#22848)

Co-authored-by: Yihao Wang <42559837+AgainstEntropy@users.noreply.github.com>
This commit is contained in:
Sam H
2026-05-27 22:44:55 +08:00
committed by GitHub
co-authored by Yihao Wang
parent 034dd39189
commit a95b4e2e09
11 changed files with 1707 additions and 49 deletions
@@ -54,6 +54,7 @@ from fastapi import (
Query,
Request,
UploadFile,
WebSocket,
)
from fastapi.exceptions import RequestValidationError
from fastapi.middleware.cors import CORSMiddleware
@@ -1605,6 +1606,17 @@ async def openai_v1_audio_transcriptions(
)
@app.websocket("/v1/realtime")
async def openai_v1_realtime_transcription(ws: WebSocket):
"""OpenAI Realtime transcription WebSocket endpoint."""
# /v1/realtime is OpenAI's unified Realtime URL covering transcription +
# chat modes. This handler implements the transcription subset only;
# chat-mode session.update payloads are rejected by the
# `Literal["transcription"]` constraint on TranscriptionSessionConfig.type
# (see realtime/protocol.py).
await ws.app.state.openai_serving_transcription.handle_websocket(ws)
@app.get("/v1/models", response_class=ORJSONResponse)
async def available_models():
"""Show available models. OpenAI-compatible endpoint."""