simulstream.server.websocket_server

Functions

cli_main()

Simulstream WebSocket server command-line interface (CLI) entry point.

connection_handler_factory(speech_processor_pool)

Factory function that creates a connection handler for the WebSocket server.

main(args)

Main entry point for running the WebSocket speech server.

Classes

SpeechProcessorPool(speech_processor_config, ...)

A pool of speech processors initialized at startup and made available to clients.

class simulstream.server.websocket_server.SpeechProcessorPool(speech_processor_config: SimpleNamespace, size: int, acquire_timeout: int)

A pool of speech processors initialized at startup and made available to clients.

Parameters:
  • speech_processor_config (SimpleNamespace) – configuration for the speech processors to create.

  • size (int) – number of speech processors to have in the pool.

  • acquire_timeout (int) – timeout (in seconds) for waiting the availability of a speech processor.

acquire()

Acquire one process from the pool and release it automatically.

Returns:

a speech processor available for usage.

Return type:

SpeechProcessor

Raises:

TimeoutError – if no speech processor is available within the configured timeout.

simulstream.server.websocket_server.cli_main()

Simulstream WebSocket server command-line interface (CLI) entry point.

This function parses command-line arguments and starts the asynchronous main() routine.

Example usage:

$ python websocket_server.py --server-config config/server.yaml \
      --speech-processor-config config/speech.yaml

Command-line arguments:

  • --server-config (str, optional): Path to the server configuration file (default: config/server.yaml).

  • --speech-processor-config (str, required): Path to the speech processor configuration file.

simulstream.server.websocket_server.connection_handler_factory(speech_processor_pool: SpeechProcessorPool) Callable[[ServerConnection], Awaitable[None]]

Factory function that creates a connection handler for the WebSocket server.

The returned connection handler routine will process audio and metadata messages sent by a single client over WebSocket.

The handler receives client data (raw audio chunks and textual metadata) and forwards it to a message processor using a speech processor retrieved form the pool of the available ones. If no speech processor is available for the configured waiting time, the client connection is closed. The handler also sends incremental processing results back to the client in JSON format.

Parameters:

speech_processor_pool (SpeechProcessorPool) – Pool of speech processors to use to handle client connections.

Returns:

An asynchronous

WebSocket connection handler coroutine.

Return type:

Callable[[websockets.asyncio.server.ServerConnection], Awaitable[None]]

async simulstream.server.websocket_server.main(args: Namespace)

Main entry point for running the WebSocket speech server.

This function loads the server and speech processor configurations from YAML, initializes logging (including metrics logging), and starts the WebSocket server on the configured host and port.

Parameters:

args (argparse.Namespace) – parsed command-line arguments with configuration file paths.