### Set Up Local Environment for Whisper-Flow Source: https://github.com/dimastatz/whisper-flow/blob/main/docs/demo1.md Navigate into the cloned directory, run the setup script, and activate the virtual environment to install dependencies. ```bash cd whisper-flow ./run.sh -local source .venv/bin/activate ``` -------------------------------- ### Setup Environment with run.sh Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Use this command to set up the project environment, install dependencies, and run tests. It creates a virtual environment, installs requirements, and runs code formatting and linting checks. ```bash # Setup environment: creates .venv, installs dependencies, runs tests ./run.sh -local ``` -------------------------------- ### Clone Repository and Setup Environment Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Initial setup commands to clone the Whisper Flow repository, install dependencies, and set up the local environment using the provided script. ```bash # Clone the repository git clone https://github.com/dimastatz/whisper-flow.git cd whisper-flow # Setup environment, install dependencies, and run tests ./run.sh -local # Activate the virtual environment source .venv/bin/activate # Start the server on port 8181 ./run.sh -run-server ``` -------------------------------- ### Install PortAudio on Linux (Fedora/RHEL) Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Command to install PortAudio development files on Fedora/RHEL systems using dnf. ```bash sudo dnf install portaudio-devel ``` -------------------------------- ### Manual Docker Setup Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Manually build the Docker image and run the container. This includes building the image, running the container, checking logs, and stopping the container. ```bash # Build the image docker build -t whisperflow-image --file Dockerfile.test . # Run the container docker run --name whisperflow-container -p 8181:8181 -d whisperflow-image # Check logs docker logs whisperflow-container # Stop the container docker stop whisperflow-container ``` -------------------------------- ### Running the Server Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Instructions on how to activate the environment and start the FastAPI server, which provides WebSocket and HTTP endpoints for transcription services. ```APIDOC ## Running the Server ### Description Start the FastAPI server on port 8181 for real-time streaming transcription and batch processing. ### Method ```bash ./run.sh -run-server ``` ### Endpoint `ws://localhost:8181/ws` - Real-time streaming transcription `GET http://localhost:8181/health` - Server status `POST http://localhost:8181/transcribe_pcm_chunk` - Process PCM audio files ``` -------------------------------- ### Install PortAudio on Linux (Ubuntu/Debian) Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Command to install PortAudio development files on Ubuntu/Debian systems using apt-get. ```bash sudo apt-get install portaudio19-dev ``` -------------------------------- ### Install PortAudio on macOS Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Command to install PortAudio using Homebrew on macOS. This is a prerequisite for PyAudio. ```bash brew install portaudio ``` -------------------------------- ### Install WhisperFlow Package Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Install the WhisperFlow package using pip to integrate its functionality into your Python applications. ```bash pip install whisperflow ``` -------------------------------- ### Start Whisper-Flow Server Locally Source: https://github.com/dimastatz/whisper-flow/blob/main/docs/demo1.md Run this command to start the Whisper-Flow server locally on port 8181, making it ready to receive transcription requests. ```bash uvicorn whisperflow.fast_server:app --host 0.0.0.0 --port 8181 ``` -------------------------------- ### Run Benchmarks with run.sh Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Activate the virtual environment and run benchmark tests. This process starts the server, runs tests, and then stops the server to measure transcription latency and word error rate. ```bash # Activate environment source .venv/bin/activate # Run benchmark tests (starts server, runs tests, stops server) ./run.sh -benchmark ``` -------------------------------- ### Run Server with run.sh Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Activate the virtual environment and start the FastAPI server. The server listens on port 8181 and provides WebSocket and HTTP endpoints for transcription. ```bash # Activate environment source .venv/bin/activate # Start the FastAPI server on port 8181 ./run.sh -run-server ``` -------------------------------- ### Run Tests with run.sh Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Activate the virtual environment and run tests. This command executes code formatting, linting, and unit tests. ```bash # Activate environment source .venv/bin/activate # Run tests only (formatting + linting + unit tests) ./run.sh -test ``` -------------------------------- ### Benchmark Latency Statistics Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Provides statistical summary of latency measurements from the benchmark. Useful for understanding performance distribution. ```bash Latency Stats: count 26.000000 mean 275.223077 std 84.525695 min 154.700000 25% 205.105000 50% 258.620000 75% 339.412500 max 470.700000 ``` -------------------------------- ### Benchmark Results Table Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Displays partial results and their corresponding latency during benchmarking. Used to evaluate real-time responsiveness. ```bash | Partial | Latency | Result | True 175.47 when we took True 185.14 When we took her. True 237.83 when we took our seat. True 176.42 when we took our seats. True 198.59 when we took our seats at the True 186.72 when we took our seats at the True 210.04 when we took our seats at the breakfast. True 220.36 when we took our seats at the breakfast table. True 203.46 when we took our seats at the breakfast table. True 242.63 When we took our seats at the breakfast table, it will True 237.41 When we took our seats at the breakfast table, it was with True 246.36 When we took our seats at the breakfast table, it was with the True 278.96 When we took our seats at the breakfast table, it was with the feeling. True 285.03 When we took our seats at the breakfast table, it was with the feeling of being. True 295.39 When we took our seats at the breakfast table, it was with the feeling of being no True 270.88 When we took our seats at the breakfast table, it was with the feeling of being no longer True 320.43 When we took our seats at the breakfast table, it was with the feeling of being no longer looked True 303.66 When we took our seats at the breakfast table, it was with the feeling of being no longer looked upon. True 470.73 When we took our seats at the breakfast table, it was with the feeling of being no longer True 353.25 When we took our seats at the breakfast table, it was with the feeling of being no longer looked upon as connected. True 345.74 When we took our seats at the breakfast table, it was with the feeling of being no longer looked upon as connected in any way. True 368.66 When we took our seats at the breakfast table, it was with the feeling of being no longer looked upon as connected in any way with the True 400.25 When we took our seats at the breakfast table, it was with the feeling of being no longer looked upon as connected in any way with this case. True 382.71 When we took our seats at the breakfast table, it was with the feeling of being no longer looked upon as connected in any way with this case. False 405.02 When we took our seats at the breakfast table, it was with the feeling of being no longer looked upon as connected in any way with this case. ``` -------------------------------- ### Clone Repository for Development Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Commands to clone the Whisper Flow repository and navigate into the project directory for development purposes. ```bash # Clone and enter the directory git clone https://github.com/dimastatz/whisper-flow.git cd whisper-flow ``` -------------------------------- ### Build and Run Docker Container Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Use this command to build and run the Docker container for WhisperFlow. It stops existing containers, removes old images, builds a new image, and runs the container on port 8888. ```bash # Build and run the Docker container ./run.sh -docker ``` -------------------------------- ### Transcriber Module - transcribe_pcm_chunks_async Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Asynchronously transcribe PCM audio chunks. ```APIDOC ## `transcribe_pcm_chunks_async` ### Description Asynchronously transcribe PCM audio chunks. ### Parameters - `model` - The loaded Whisper model. - `chunks` (list) - A list of PCM audio data chunks. - `lang` (string, optional) - The language of the audio. Defaults to "en". ``` -------------------------------- ### Streaming Module - TranscribeSession Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Create a session for streaming transcription. ```APIDOC ## `TranscribeSession` ### Description Create a streaming transcription session. ### Parameters - `transcribe_fn` - The function to call for transcription. - `send_back_fn` - The function to call to send back transcription results. ``` -------------------------------- ### Clone Whisper-Flow Repository Source: https://github.com/dimastatz/whisper-flow/blob/main/docs/demo1.md Use this command to clone the Whisper-Flow repository from GitHub to access all necessary files for local execution. ```bash git clone https://github.com/dimastatz/whisper-flow.git ``` -------------------------------- ### Transcriber Module - transcribe_pcm_chunks Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Synchronously transcribe PCM audio chunks. ```APIDOC ## `transcribe_pcm_chunks` ### Description Synchronously transcribe PCM audio chunks. ### Parameters - `model` - The loaded Whisper model. - `chunks` (list) - A list of PCM audio data chunks. - `lang` (string, optional) - The language of the audio. Defaults to "en". ``` -------------------------------- ### Transcriber Module - get_model Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Load a Whisper model for transcription. ```APIDOC ## `get_model` ### Description Load a Whisper model. ### Parameters - `file_name` (string, optional) - The name of the model file. Defaults to "tiny.en.pt". ``` -------------------------------- ### WebSocket Endpoint Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Real-time streaming transcription via WebSocket. ```APIDOC ## WebSocket Endpoint ### Description Establish a WebSocket connection for real-time streaming transcription. ### Endpoint `ws://localhost:8181/ws` ``` -------------------------------- ### Streaming Module - session.add_chunk Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Add an audio chunk to the transcription session. ```APIDOC ## `session.add_chunk` ### Description Add an audio chunk to the transcription session for processing. ### Parameters - `audio_data` (bytes) - The raw audio data chunk. ``` -------------------------------- ### Batch Transcription Endpoint Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Endpoint for processing PCM audio files in batches. ```APIDOC ## Batch Transcription ### Description Process PCM audio files for transcription. ### Method POST ### Endpoint `http://localhost:8181/transcribe_pcm_chunk` ``` -------------------------------- ### Real-time Streaming Transcription WebSocket Endpoint Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md This Python code sets up a FastAPI application with a WebSocket endpoint for real-time streaming transcription. It loads a Whisper model, defines transcription and response callbacks, and processes incoming audio chunks. ```python from fastapi import FastAPI, WebSocket from starlette.websockets import WebSocketDisconnect import whisperflow.streaming as st import whisperflow.transcriber as ts app = FastAPI() @app.websocket("/ws") async def websocket_endpoint(websocket: WebSocket): # Load the Whisper model (default: tiny.en.pt) model = ts.get_model() # Define transcription callback async def transcribe_async(chunks: list): return await ts.transcribe_pcm_chunks_async(model, chunks) # Define response callback async def send_back_async(data: dict): await websocket.send_json(data) try: await websocket.accept() # Create transcription session session = st.TranscribeSession(transcribe_async, send_back_async) # Process incoming audio chunks while True: data = await websocket.receive_bytes() session.add_chunk(data) except WebSocketDisconnect: # Client disconnected await session.stop() except Exception as exception: # Handle errors await session.stop() if websocket.client_state.name != "DISCONNECTED": await websocket.close() ``` -------------------------------- ### Streaming Module - session.stop Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md Stop the transcription session. ```APIDOC ## `session.stop` ### Description Stop the streaming transcription session and release resources. ``` -------------------------------- ### Health Check Endpoint Source: https://github.com/dimastatz/whisper-flow/blob/main/README.md The health check endpoint provides the server status. ```APIDOC ## Health Check ### Description Check the status of the running server. ### Method GET ### Endpoint `http://localhost:8181/health` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.