simulstream.client.wav_reader_client
Functions
|
Simulstream WebSocket client command-line interface (CLI) entry point. |
|
Convert a NumPy array of float32 audio samples to int16 PCM format. |
|
Load a list of WAV file paths from a text file. |
|
Main entrypoint: validates WAV files and starts streaming. |
|
Read a WAV file and return its sample rate and audio data. |
|
Stream audio data in fixed-size chunks over a WebSocket connection. |
|
Stream multiple WAV files sequentially to a WebSocket server. |
- simulstream.client.wav_reader_client.cli_main()
Simulstream WebSocket client command-line interface (CLI) entry point.
This script implements a simple WebSocket client that streams audio data from a list of WAV files to a server for processing (e.g., speech recognition or translation). It reads WAV files, converts them into fixed-size chunks, and sends them asynchronously over a WebSocket connection.
Example usage:
$ python wav_reader_client.py --uri ws://localhost:8000/ --wav-list-file wav_files.txt \ --tgt-lang it --src-lang enCommand-line arguments:
--uri: WebSocket server URI (e.g.,ws://localhost:8000/).--wav-list-file: Path to a text file containing one WAV file path per line.--chunk-duration-ms: Duration of each audio chunk sent to the server (ms). Default: 100.--tgt-lang: Optional target language.--src-lang: Optional source language.
- simulstream.client.wav_reader_client.float32_to_int16(audio_data: ndarray) ndarray
Convert a NumPy array of float32 audio samples to int16 PCM format.
- simulstream.client.wav_reader_client.load_wav_file_list(list_file_path: str) List[str]
Load a list of WAV file paths from a text file.
- async simulstream.client.wav_reader_client.main(args: Namespace)
Main entrypoint: validates WAV files and starts streaming.
- simulstream.client.wav_reader_client.read_wav_file(filename: str) Tuple[int, ndarray]
Read a WAV file and return its sample rate and audio data.
- Parameters:
filename (str) – Path to the WAV file.
- Returns:
Sample rate and mono audio data as int16 array.
- Return type:
- Raises:
ValueError – If the sample width is unsupported.
AssertionError – If the file contains more than one channel.
- async simulstream.client.wav_reader_client.send_audio(websocket: ClientConnection, sample_rate: int, data: ndarray, chunk_duration_ms: int = 100)
Stream audio data in fixed-size chunks over a WebSocket connection.
- async simulstream.client.wav_reader_client.stream_wav_files(uri: str, wav_file_list: List[str], chunk_duration_ms: int = 100, tgt_lang: str | None = None, src_lang: str | None = None)
Stream multiple WAV files sequentially to a WebSocket server.
- For each file:
Sends metadata (sample rate, filename, optional languages).
Streams audio in chunks.
Sends an end-of-stream marker.
Waits for server confirmation before proceeding.