mstar.api_server.openai.serving_realtime#
/v1/realtime (transcription intent): streaming speech-to-text over a WebSocket.
A subset of OpenAI’s Realtime transcription session, enough for a client that streams microphone audio and wants partial transcripts:
- Client events
transcription_session.update{"session": {"input_audio_transcription": {"model", "language", "prompt"}, "input_audio_format": "pcm16", "mstar": {"chunk_seconds", "unfixed_chunks", "unfixed_tokens"}}}input_audio_buffer.append{"audio": <base64 PCM16 mono 16 kHz>}input_audio_buffer.commitend of the utterance: flush and finishinput_audio_buffer.cleardrop buffered audio and start over- Server events
transcription_session.created/.updatedconversation.item.input_audio_transcription.deltaappend-only textmstar.transcription.partialthe whole current hypothesis, unstable tail includedconversation.item.input_audio_transcription.completed{"transcript"}error
The decoding follows the Qwen3-ASR SDK’s streaming algorithm: every
chunk_seconds of new audio, the audio heard so far is transcribed again
as one engine request whose assistant turn is prefilled with the previous
hypothesis minus its last unfixed_tokens tokens (once unfixed_chunks
chunks are in), so the tail can still be revised while the head is fixed.
The adapter decides how that prefix reaches its model
(realtime_step_request). Each step is an ordinary request, so sessions
batch on the engine like any other traffic.
Functions
|
Base64 PCM16 (little-endian, mono) -> float32 in [-1, 1). |
|
|
Classes
|
One WebSocket's transcription state (the SDK's |
|
Drives one WebSocket session against the API server. |
- class mstar.api_server.openai.serving_realtime.RealtimeSession(session_id, request, chunk_seconds=2.0, unfixed_chunks=2, unfixed_tokens=5, pending=<factory>, pending_samples=0, heard=<factory>, chunk_id=0, raw_hypothesis='', emitted='', item_id=<factory>)[source]#
Bases:
objectOne WebSocket’s transcription state (the SDK’s
ASRStreamingState).- Parameters:
- request: TranscriptionRequest#
- class mstar.api_server.openai.serving_realtime.RealtimeTranscription(api, model_name, adapter, websocket)[source]#
Bases:
objectDrives one WebSocket session against the API server.
- Parameters:
model_name (str)
websocket (WebSocket)
- async emit(text, hold)[source]#
Send the part of
textpast what was already sent, minus the lastholdcharacters. A revision that reaches into sent text is not resent — deltas are append-only — the partial event carries it.