sofdog-gh/realtime-transcription-fastrtc

Real Time Speech Transcription with FastRTC ⚑️and Local Whisper πŸ€—

701

stars

35

commits

Python

primary language

Jul 10, 2025

updated

README

Live Speech Transcription powered by FastRTC ⚑️ and Local Whisper πŸ€—

This project uses FastRTC to handle live interaction between audio input and text output, and open-source Automatic Speech Recognition (ASR) models via Transformers.

Quick Start πŸš€

System Requirements

  • Python β‰₯3.10
  • ffmpeg
  • CUDA-compatible GPU (optional, for faster inference)
# 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!

Detailed Installation

1. Environment Setup

Choose your preferred package manager:

πŸ“¦ UV (recommended)

Install uv

uv venv --python 3.11 && source .venv/bin/activate
uv pip install -r requirements.txt
🐍 pip
python -m venv .venv && source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt

2. Install ffmpeg

🍎 macOS
brew install ffmpeg
🐧 Linux (Ubuntu/Debian)
sudo apt update
sudo apt install ffmpeg

Configuration

The application can be configured using environment variables. Create a .env file in the project root with the following variables:

VariableDescriptionPossible ValuesDefault
UI_MODEInterface type to usefastapi (custom UI), gradio (default Gradio UI)fastapi
UI_TYPEUI template to use when UI_MODE=fastapibase, screenbase
APP_MODEDeployment modelocal, deployedlocal
TURN_PROVIDERTURN server provider when APP_MODE=deployedhf-cloudflare, cloudflare, twiliohf-cloudflare
MODEL_IDHuggingFace model identifierAnyopenai/whisper-large-v3-turbo
LANGUAGETarget language for transcriptionAny valid or Noneenglish
SERVER_NAMEHost to bind toAny valid hostnamelocalhost
PORTPort numberAny valid port7860

Model Selection

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.

Docker 🐳

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).

πŸ–₯️ CPU-Only
# Using docker-compose
docker-compose --profile cpu up --build

# Or build manually
docker build -f Dockerfile.cpu -t realtime-transcription-fastrtc-cpu .
πŸš€ GPU Deployment (NVIDIA)
# 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.

Deploying on HF Spaces πŸ€—

  1. Create a new Space on HuggingFace
  2. Select Docker SDK
  3. Choose your hardware (CPU/GPU)
  4. Set variables and secrets in the Space's settings (see here)
  5. Clone your Space's repository
  6. Copy the app contents to the new repository
  7. Rename either Dockerfile.cpu or Dockerfile.cuda to Dockerfile based on your hardware choice (see previous section about Docker 🐳)
  8. Push to your Space!

For deployed environments:

  • Set APP_MODE=deployed
  • Set TURN_PROVIDER to your chosen provider (cloudflare, hf-cloudflare, or twilio)
  • Configure the corresponding TURN server credentials in your Space's secrets

Additional Resources

Contributors

sofdog-gh

33 commits

Vaibhavs10

2 commits

sofdog-gh/realtime-transcription-fastrtc

Real Time Speech Transcription with FastRTC ⚑️and Local Whisper πŸ€—

701

stars

35

commits

Python

primary language

Jul 10, 2025

updated

README

Live Speech Transcription powered by FastRTC ⚑️ and Local Whisper πŸ€—

This project uses FastRTC to handle live interaction between audio input and text output, and open-source Automatic Speech Recognition (ASR) models via Transformers.

Quick Start πŸš€

System Requirements

  • Python β‰₯3.10
  • ffmpeg
  • CUDA-compatible GPU (optional, for faster inference)
# 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!

Detailed Installation

1. Environment Setup

Choose your preferred package manager:

πŸ“¦ UV (recommended)

Install uv

uv venv --python 3.11 && source .venv/bin/activate
uv pip install -r requirements.txt
🐍 pip
python -m venv .venv && source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt

2. Install ffmpeg

🍎 macOS
brew install ffmpeg
🐧 Linux (Ubuntu/Debian)
sudo apt update
sudo apt install ffmpeg

Configuration

The application can be configured using environment variables. Create a .env file in the project root with the following variables:

VariableDescriptionPossible ValuesDefault
UI_MODEInterface type to usefastapi (custom UI), gradio (default Gradio UI)fastapi
UI_TYPEUI template to use when UI_MODE=fastapibase, screenbase
APP_MODEDeployment modelocal, deployedlocal
TURN_PROVIDERTURN server provider when APP_MODE=deployedhf-cloudflare, cloudflare, twiliohf-cloudflare
MODEL_IDHuggingFace model identifierAnyopenai/whisper-large-v3-turbo
LANGUAGETarget language for transcriptionAny valid or Noneenglish
SERVER_NAMEHost to bind toAny valid hostnamelocalhost
PORTPort numberAny valid port7860

Model Selection

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.

Docker 🐳

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).

πŸ–₯️ CPU-Only
# Using docker-compose
docker-compose --profile cpu up --build

# Or build manually
docker build -f Dockerfile.cpu -t realtime-transcription-fastrtc-cpu .
πŸš€ GPU Deployment (NVIDIA)
# 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.

Deploying on HF Spaces πŸ€—

  1. Create a new Space on HuggingFace
  2. Select Docker SDK
  3. Choose your hardware (CPU/GPU)
  4. Set variables and secrets in the Space's settings (see here)
  5. Clone your Space's repository
  6. Copy the app contents to the new repository
  7. Rename either Dockerfile.cpu or Dockerfile.cuda to Dockerfile based on your hardware choice (see previous section about Docker 🐳)
  8. Push to your Space!

For deployed environments:

  • Set APP_MODE=deployed
  • Set TURN_PROVIDER to your chosen provider (cloudflare, hf-cloudflare, or twilio)
  • Configure the corresponding TURN server credentials in your Space's secrets

Additional Resources

Contributors

sofdog-gh

33 commits

Vaibhavs10

2 commits

Languages

Python

41.4%

JavaScript

34.6%

HTML

23.9%