Skip to content

vllm.entrypoints.speech_to_text.realtime.connection

Classes:

  • RealtimeConnection –

    Manages WebSocket lifecycle and state for realtime transcription.

RealtimeConnection

Manages WebSocket lifecycle and state for realtime transcription.

This class handles: - WebSocket connection lifecycle (accept, receive, send, close) - Event routing (session.update, append, commit) - Audio buffering via asyncio.Queue - Generation task management - Error handling and cleanup

Methods:

_run_generation(streaming_input_gen, input_stream) async

Run the generation and stream results back to the client.

This method: 1. Creates sampling parameters from session config 2. Passes the streaming input generator to engine.generate() 3. Streams transcription.delta events as text is generated 4. Sends final transcription.done event with usage stats 5. Feeds generated token IDs back to input_stream for next iteration 6. Cleans up the audio queue

audio_stream_generator() async

Generator that yields audio chunks from the queue.

cleanup() async

Cleanup resources.

handle_connection() async

Main connection loop.

handle_event(event) async

Route events to handlers.

Supported event types: - session.update: Configure model - input_audio_buffer.append: Add audio chunk to queue - input_audio_buffer.commit: Start transcription generation

send(event) async

Send event to client.

send_error(message, code=None) async

Send error event to client.

start_generation() async

Start the transcription generation task.