Spaces:
Running
Running
File size: 6,687 Bytes
c95ad37 940e218 c95ad37 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | ---
title: Reachy Mini F1 Commentator
emoji: ποΈ
colorFrom: red
colorTo: blue
sdk: static
pinned: false
short_description: An interactive F1 race commentary system for Reachy Mini
tags:
- reachy_mini
- reachy_mini_python_app
---
# ποΈ Reachy F1 Commentator
An interactive F1 race commentary system for Reachy Mini that generates organic, context-rich commentary with audio synthesis and synchronized robot movements.
## Features
- ποΈ **Enhanced Organic Commentary** - 210 templates with varied perspectives (technical, strategic, dramatic)
- π **Quick Demo Mode** - 2-3 minute pre-configured demonstration
- π **Full Historical Race Mode** - Replay any F1 race from OpenF1 API
- π **Audio Synthesis** - ElevenLabs text-to-speech integration
- π€ **Robot Movements** - Synchronized head movements with commentary
- π **Web UI** - Browser-based race selection and playback control
- β‘ **Configurable Speed** - 1x, 5x, 10x, or 20x playback speed
## Installation
### Via Reachy Mini App Assistant
The easiest way to install this app on your Reachy Mini:
```bash
reachy-mini-app-assistant install reachy-f1-commentator
```
### Manual Installation
```bash
pip install git+https://huggingface.co/spaces/YOUR_USERNAME/reachy-f1-commentator
```
## Usage
### Starting the App
The app runs automatically when started from the Reachy Mini dashboard. It will:
1. Start a web server at `http://localhost:5173` (or configured port)
2. Open the web UI for race selection
3. Wait for you to configure and start commentary
### Web UI Controls
**Mode Selection:**
- **Quick Demo** - 2-3 minute demonstration with pre-configured events
- **Full Historical Race** - Select from available F1 races
**Race Selection** (Full Historical Race mode):
- **Year** - Select from available years (2018-2024)
- **Race** - Select specific race from chosen year
**Configuration:**
- **Commentary Mode** - Basic or Enhanced (Enhanced recommended)
- **Playback Speed** - 1x (real-time), 5x, 10x, or 20x
- **ElevenLabs API Key** - Your ElevenLabs API key for audio synthesis
- **Voice ID** - ElevenLabs voice ID (default provided)
**Controls:**
- **Start Commentary** - Begin playback with selected configuration
- **Stop** - Halt active commentary
### Configuration
#### ElevenLabs API Key
To enable audio synthesis, you need an ElevenLabs API key:
1. Sign up at [ElevenLabs](https://elevenlabs.io/)
2. Get your API key from the dashboard
3. Enter it in the Web UI before starting commentary
#### Environment Variables (Optional)
You can also set credentials via environment variables:
```bash
export ELEVENLABS_API_KEY="your_api_key_here"
export ELEVENLABS_VOICE_ID="your_voice_id_here"
```
## Quick Demo Mode
Perfect for showcasing the system without internet connectivity:
- Pre-configured 2-3 minute demonstration
- Includes overtakes, pit stops, fastest lap, and incidents
- Demonstrates commentary variety and robot movements
- No OpenF1 API connection required
## Full Historical Race Mode
Experience past F1 races with generated commentary:
- Select from 100+ historical races (2018-2024)
- Configurable playback speed (1x to 20x)
- Real race data from OpenF1 API
- Complete race commentary with all significant events
## Enhanced Commentary System
The enhanced commentary system generates organic, natural-sounding commentary:
- **210 Templates** - Extensive variety prevents repetition
- **5 Excitement Levels** - Calm to dramatic based on event significance
- **5 Perspectives** - Technical, strategic, dramatic, positional, historical
- **Context Enrichment** - Multiple data points per commentary
- **Narrative Tracking** - Detects battles, comebacks, strategy divergence
- **Frequency Controls** - Prevents repetitive content patterns
### Example Commentary
**Basic Mode:**
```
"Hamilton gets past Verstappen! Up to P1!"
```
**Enhanced Mode:**
```
"Fantastic overtake by Hamilton on Verstappen, now in P1!"
"There it is! Hamilton takes the lead from Verstappen!"
"Hamilton makes a brilliant move on Verstappen for P1!"
```
## Requirements
- **Reachy Mini** (or simulation mode)
- **Python 3.9+**
- **ElevenLabs API Key** (for audio synthesis)
- **Internet Connection** (for Full Historical Race mode)
## Development
### Running in Standalone Mode
For development and testing without the Reachy Mini framework:
```bash
# Method 1: Run main module directly (recommended)
python -m reachy_f1_commentator.main
# Method 2: Use the app.py wrapper
python reachy_f1_commentator/app.py
```
The app will:
- Auto-detect and connect to Reachy if available
- Fall back to text-only mode if Reachy is not connected
- Start web server on http://localhost:8080
### Testing Reachy Connection
To verify Reachy Mini connection and audio capabilities:
```bash
python test_reachy_audio_connection.py
```
This will check:
- β
Reachy Mini SDK installation
- β
Connection to Reachy
- β
Audio capabilities
- β
Simple audio playback test
### Running Tests
```bash
# Run all tests
pytest
# Run specific test file
pytest tests/test_enhanced_commentary_generator.py
# Run with coverage
pytest --cov=reachy_f1_commentator
```
## Architecture
```
reachy_f1_commentator/
βββ main.py # ReachyMiniF1Commentator app class
βββ static/ # Web UI assets
β βββ index.html
β βββ main.js
β βββ style.css
βββ src/ # Commentary generation components
β βββ enhanced_commentary_generator.py
β βββ speech_synthesizer.py
β βββ motion_controller.py
β βββ ...
βββ config/ # Configuration and templates
β βββ enhanced_templates.json
β βββ config_enhanced_example.json
βββ tests/ # Test suite
```
## Credits
Based on the **F1 Commentary Robot** project with **Enhanced Organic Commentary System**.
### Key Features:
- Enhanced commentary generation with 210 templates
- Context enrichment from multiple OpenF1 API endpoints
- Event significance scoring with context bonuses
- Narrative thread tracking (battles, comebacks, strategy)
- Dynamic commentary styles (5 excitement levels Γ 5 perspectives)
- Frequency controls for content variety
## License
MIT License - See LICENSE file for details
## Support
For issues, questions, or contributions:
- Open an issue on the repository
- Check the documentation
- Join the Reachy Mini community
## Acknowledgments
- **Pollen Robotics** - Reachy Mini platform
- **Hugging Face** - App hosting and distribution
- **OpenF1** - Historical race data API
- **ElevenLabs** - Text-to-speech synthesis
|