This project uses FastRTC to handle live interaction between audio input and text output, and open-source Automatic Speech Recognition (ASR) models via Transformers.
System Requirements
# Clone and enter directory
git clone https://github.com/sofi444/realtime-transcription-fastrtc
cd realtime-transcription-fastrtc
# Set up environment
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
# Run with default settings
python main.py
Visit the URL shown in the terminal (default: https://localhost:7860) to start transcribing!
Choose your preferred package manager:
uv venv --python 3.11 && source .venv/bin/activate
uv pip install -r requirements.txt
python -m venv .venv && source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
brew install ffmpeg
sudo apt update
sudo apt install ffmpeg
The application can be configured using environment variables. Create a .env file in the project root with the following variables:
| Variable | Description | Possible Values | Default |
|---|---|---|---|
UI_MODE | Interface type to use | fastapi (custom UI), gradio (default Gradio UI) | fastapi |
UI_TYPE | UI template to use when UI_MODE=fastapi | base, screen | base |
APP_MODE | Deployment mode | local, deployed | local |
TURN_PROVIDER | TURN server provider when APP_MODE=deployed | hf-cloudflare, cloudflare, twilio | hf-cloudflare |
MODEL_ID | HuggingFace model identifier | Any | openai/whisper-large-v3-turbo |
LANGUAGE | Target language for transcription | Any valid or None | english |
SERVER_NAME | Host to bind to | Any valid hostname | localhost |
PORT | Port number | Any valid port | 7860 |
You can use any Whisper model version or other ASR model from Hugging Face. The default whisper-large-v3-turbo is recommended as it's lightweight, performant and multi-lingual.
We use batch size 1 to start transcribing as soon as a chunk is available.
I provide a Docker setup for both CPU and GPU: Dockerfile.cpu and Dockerfile.cuda, helpful if you want to deploy the app in a container.
The Dockerfiles use uv as environment and package manager.
Dockerfile.cuda includes Flash Attention installation for faster inference (https://github.com/Dao-AILab/flash-attention).
# Using docker-compose
docker-compose --profile cpu up --build
# Or build manually
docker build -f Dockerfile.cpu -t realtime-transcription-fastrtc-cpu .
# Using docker-compose
docker-compose --profile cuda up --build
# Or build manually
docker build -f Dockerfile.cuda -t realtime-transcription-fastrtc-cuda .
Note: Requires NVIDIA GPU with CUDA 12.1. Change base image in Dockerfile.cuda to match your CUDA version.
Dockerfile.cpu or Dockerfile.cuda to Dockerfile based on your hardware choice (see previous section about Docker π³)For deployed environments:
APP_MODE=deployedTURN_PROVIDER to your chosen provider (cloudflare, hf-cloudflare, or twilio)33 commits
2 commits
Python
41.4%
JavaScript
34.6%
HTML
23.9%
This project uses FastRTC to handle live interaction between audio input and text output, and open-source Automatic Speech Recognition (ASR) models via Transformers.
System Requirements
# Clone and enter directory
git clone https://github.com/sofi444/realtime-transcription-fastrtc
cd realtime-transcription-fastrtc
# Set up environment
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
# Run with default settings
python main.py
Visit the URL shown in the terminal (default: https://localhost:7860) to start transcribing!
Choose your preferred package manager:
uv venv --python 3.11 && source .venv/bin/activate
uv pip install -r requirements.txt
python -m venv .venv && source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
brew install ffmpeg
sudo apt update
sudo apt install ffmpeg
The application can be configured using environment variables. Create a .env file in the project root with the following variables:
| Variable | Description | Possible Values | Default |
|---|---|---|---|
UI_MODE | Interface type to use | fastapi (custom UI), gradio (default Gradio UI) | fastapi |
UI_TYPE | UI template to use when UI_MODE=fastapi | base, screen | base |
APP_MODE | Deployment mode | local, deployed | local |
TURN_PROVIDER | TURN server provider when APP_MODE=deployed | hf-cloudflare, cloudflare, twilio | hf-cloudflare |
MODEL_ID | HuggingFace model identifier | Any | openai/whisper-large-v3-turbo |
LANGUAGE | Target language for transcription | Any valid or None | english |
SERVER_NAME | Host to bind to | Any valid hostname | localhost |
PORT | Port number | Any valid port | 7860 |
You can use any Whisper model version or other ASR model from Hugging Face. The default whisper-large-v3-turbo is recommended as it's lightweight, performant and multi-lingual.
We use batch size 1 to start transcribing as soon as a chunk is available.
I provide a Docker setup for both CPU and GPU: Dockerfile.cpu and Dockerfile.cuda, helpful if you want to deploy the app in a container.
The Dockerfiles use uv as environment and package manager.
Dockerfile.cuda includes Flash Attention installation for faster inference (https://github.com/Dao-AILab/flash-attention).
# Using docker-compose
docker-compose --profile cpu up --build
# Or build manually
docker build -f Dockerfile.cpu -t realtime-transcription-fastrtc-cpu .
# Using docker-compose
docker-compose --profile cuda up --build
# Or build manually
docker build -f Dockerfile.cuda -t realtime-transcription-fastrtc-cuda .
Note: Requires NVIDIA GPU with CUDA 12.1. Change base image in Dockerfile.cuda to match your CUDA version.
Dockerfile.cpu or Dockerfile.cuda to Dockerfile based on your hardware choice (see previous section about Docker π³)For deployed environments:
APP_MODE=deployedTURN_PROVIDER to your chosen provider (cloudflare, hf-cloudflare, or twilio)33 commits
2 commits
Python
41.4%
JavaScript
34.6%
HTML
23.9%