File size: 4,993 Bytes
83f23c7 20aec87 eaf056f |
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 |
---
title: Twenty Questions Game
emoji: ๐
colorFrom: red
colorTo: blue
sdk: static
pinned: false
short_description: Write your description here
tags:
- reachy_mini
- reachy_mini_python_app
---
# ๐คโ 20 Questions - Reachy Mini App
Play the classic guessing game with Reachy Mini! The robot thinks of something, and you have 20 yes/no questions to figure out what it is.
**Powered by OpenAI Realtime API for natural voice conversation.**
## โจ Features
- ๐ค **Voice Conversation** - Talk naturally, no buttons needed
- ๐ญ **Expressive Robot** - Watch Reachy react with emotions
- ๐ง **Smart AI** - Natural conversation powered by OpenAI
- ๐ **Real-time Audio** - Low-latency speech-to-speech
## ๐ Requirements
- Reachy Mini robot (Lite or Wireless)
- OpenAI API key with Realtime API access
- Python 3.10+
## ๐ Installation
### Method 1: From Hugging Face (Recommended)
1. Open the Reachy Mini dashboard: `http://localhost:8000`
2. Find "20 Questions" in the app store
3. Click **Install**
### Method 2: Manual Installation
```bash
# Clone or download the app
git clone https://huggingface.co/spaces/YOUR_USERNAME/reachy_mini_twenty_questions
# Install in your Reachy Mini environment
cd reachy_mini_twenty_questions
pip install -e .
```
## โ๏ธ Configuration
### Required: Set your OpenAI API Key
```bash
export OPENAI_API_KEY=your-openai-api-key
```
Add this to your `~/.bashrc` or `~/.zshrc` to make it permanent.
### Optional: Audio Sample Rates
If transcription isn't working well, you may need to adjust the sample rates in `main.py`:
```python
# Common values based on your hardware
REACHY_INPUT_SAMPLE_RATE = 16000 # Try: 16000, 44100, 48000
REACHY_OUTPUT_SAMPLE_RATE = 48000 # Try: 24000, 44100, 48000
```
To diagnose audio issues, check the logs when the app starts.
## ๐ฎ How to Play
1. **Start the app** from the Reachy Mini dashboard
2. **Listen** to Reachy explain the rules
3. **Ask yes/no questions** like:
- "Is it alive?"
- "Is it bigger than a car?"
- "Can you eat it?"
4. **Make your guess** when you think you know: "Is it a pizza?"
5. **Say "play again"** to start a new game
## ๐ก Tips
- Start with broad questions to narrow down categories
- Listen to Reachy's tone - it gets nervous when you're close!
- You can interrupt Reachy if you have an idea
- The robot thinks of: animals, food, objects, and nature things
## ๐งช Testing
Before running the full app, you can test the OpenAI connection and audio utilities:
```bash
python test_openai_connection.py
```
This script tests:
- OpenAI API connection and authentication
- Event receiving from OpenAI
- Audio conversion utilities
- Reachy Mini integration (if available)
## ๐ง Troubleshooting
### "OPENAI_API_KEY not set"
Make sure you've exported your API key or added it to a `.env` file:
```bash
export OPENAI_API_KEY=sk-your-key-here
```
Or create a `.env` file in the project root:
```
OPENAI_API_KEY=sk-your-key-here
```
### Transcription is garbled or wrong
This usually means the audio sample rate doesn't match. Try:
1. Check your Reachy Mini's audio hardware specs
2. Update `REACHY_INPUT_SAMPLE_RATE` in `main.py`
3. Common values: `16000`, `44100`, `48000`
### Robot doesn't respond
1. Check that the OpenAI API key is valid
2. Ensure you have Realtime API access (may require specific tier)
3. Check your internet connection
### Audio is choppy
1. Try adjusting `REACHY_OUTPUT_SAMPLE_RATE`
2. Ensure your Reachy Mini isn't running other intensive apps
## ๐๏ธ Architecture
```
User Voice โ Reachy Mic โ Audio Conversion โ OpenAI Realtime API
โ
Robot Gestures โ Game State โ AI Response โ Voice Response
```
- **Audio Utils**: Converts between Reachy (varies) and OpenAI (24kHz PCM16)
- **Game State**: Tracks questions, manages phases, generates prompts
- **OpenAI Handler**: WebSocket connection to Realtime API
- **Robot Expressions**: Maps game emotions to antenna/head movements
## ๐ Project Structure
```
reachy_mini_twenty_questions/
โโโ pyproject.toml # Package definition
โโโ index.html # HuggingFace Space landing page
โโโ style.css # Landing page styles
โโโ README.md # This file
โโโ reachy_mini_twenty_questions/
โโโ __init__.py # Package exports
โโโ main.py # ReachyMiniApp class
โโโ audio_utils.py # Audio format conversion
โโโ game_state.py # Game logic & prompts
โโโ static/
โโโ index.html # Settings web UI
```
## ๐ค Contributing
Found a bug or have an idea? Open an issue or PR!
## ๐ License
Apache 2.0
## ๐ Acknowledgments
- [Pollen Robotics](https://pollen-robotics.com/) for Reachy Mini
- [OpenAI](https://openai.com/) for the Realtime API
- [Hugging Face](https://huggingface.co/) for hosting
|