File size: 7,789 Bytes
205bd66
 
 
 
 
 
 
 
 
 
 
090f72c
 
 
205bd66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23c71b8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205bd66
 
 
 
 
 
 
 
 
 
 
 
 
fcdfcdf
 
 
 
 
 
 
205bd66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
---
title: Reachy Mini Home Assistant Voice Assistant
emoji: πŸ€–
colorFrom: blue
colorTo: purple
sdk: static
pinned: false
---

# Reachy Mini Home Assistant Voice Assistant

A voice assistant application that runs on **Reachy Mini robot** and integrates with Home Assistant via the ESPHome protocol.

> **Note**: This application runs directly on the Reachy Mini robot (Raspberry Pi 4), not on Hugging Face Spaces. The Hugging Face Space is used for code hosting and documentation only.

## Features

- 🎀 **Offline Wake Word Detection**: Uses microWakeWord or openWakeWord for local wake word detection
- πŸ”„ **ESPHome Integration**: Seamlessly integrates with Home Assistant through ESPHome protocol
- πŸ€– **Motion Control**: Full control over Reachy Mini's head movements and antenna animations
- ⚑ **Low Latency**: Optimized for real-time voice interaction
- 🎭 **Expressive**: Speech-reactive motions and gestures

## Architecture

This project is based on [OHF-Voice/linux-voice-assistant](https://github.com/OHF-Voice/linux-voice-assistant) and adapted for Reachy Mini robot.

**Key Design**:
- STT (Speech-to-Text) and TTS (Text-to-Speech) are handled by Home Assistant
- Audio streams are transmitted via ESPHome protocol
- Wake word detection is processed locally on the robot
- Motion control enhances the voice interaction experience

## Installation

### Prerequisites

- Python 3.8 or higher
- Reachy Mini robot
- Home Assistant with ESPHome integration

### Quick Installation (Recommended)

```bash
# Clone the repository
git clone https://github.com/yourusername/reachy_mini_ha_voice.git
cd reachy_mini_ha_voice

# Run the automated installation script
# For Linux/Mac:
./install.sh

# For Windows:
powershell -ExecutionPolicy Bypass -File install.ps1
```

The automated installation script will:
- βœ“ Check Python version
- βœ“ Create virtual environment
- βœ“ Install all dependencies
- βœ“ Download wake word models and sound effects
- βœ“ Create configuration file
- βœ“ Check Reachy Mini SDK installation
- βœ“ Check audio devices

### Manual Installation

```bash
# Clone the repository
git clone https://github.com/yourusername/reachy_mini_ha_voice.git
cd reachy_mini_ha_voice

# Create virtual environment
python -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -e .

# Download wake word models and sound effects
# For Linux/Mac:
./download_models.sh

# For Windows:
powershell -ExecutionPolicy Bypass -File download_models.ps1

# Copy environment template
cp .env.example .env

# Configure your settings
# Edit .env file with your preferences
```

## Usage

### Basic Usage

```bash
# Start the voice assistant
python -m reachy_mini_ha_voice

# With custom configuration
python -m reachy_mini_ha_voice \
  --name "My Reachy Mini" \
  --audio-input-device "Microphone Name" \
  --audio-output-device "Speaker Name" \
  --wake-model okay_nabu
```

### List Audio Devices

```bash
# List available input devices
python -m reachy_mini_ha_voice --list-input-devices

# List available output devices
python -m reachy_mini_ha_voice --list-output-devices
```

### Web UI

```bash
# Start with Gradio web interface
python -m reachy_mini_ha_voice --gradio
```

### Wireless Version

```bash
# For wireless Reachy Mini
python -m reachy_mini_ha_voice --wireless
```

## Configuration

### Environment Variables

Create a `.env` file (copy from `.env.example`):

```env
# Audio Configuration
AUDIO_INPUT_DEVICE=
AUDIO_OUTPUT_DEVICE=
AUDIO_SAMPLE_RATE=16000
AUDIO_CHANNELS=1
AUDIO_BLOCK_SIZE=1024

# Voice Configuration
WAKE_WORD=okay_nabu
WAKE_WORD_DIR=wakewords

# Motion Configuration
MOTION_ENABLED=true
SPEECH_REACTIVE=true

# ESPHome Configuration
ESPHOME_HOST=0.0.0.0
ESPHOME_PORT=6053
ESPHOME_NAME=Reachy Mini

# Robot Configuration
ROBOT_HOST=localhost
ROBOT_WIRELESS=false

# Logging
LOG_LEVEL=INFO
```

### Configuration File

You can also use a `config.json` file:

```json
{
  "audio": {
    "input_device": null,
    "output_device": null,
    "sample_rate": 16000,
    "channels": 1,
    "block_size": 1024
  },
  "voice": {
    "wake_word": "okay_nabu",
    "wake_word_dirs": ["wakewords"]
  },
  "motion": {
    "enabled": true,
    "speech_reactive": true
  },
  "esphome": {
    "host": "0.0.0.0",
    "port": 6053,
    "name": "Reachy Mini"
  },
  "robot": {
    "host": "localhost",
    "wireless": false
  }
}
```

## Home Assistant Integration

### Step 1: Add ESPHome Integration

1. Go to Home Assistant β†’ Settings β†’ Devices & Services
2. Click "Add Integration"
3. Search for "ESPHome"
4. Click "Set up another instance of ESPHome"
5. Enter your Reachy Mini's IP address and port (default: 6053)
6. Click "Submit"

### Step 2: Configure Voice Assistant

Home Assistant should automatically detect the voice assistant. You can then:

- Set up voice commands
- Create automations
- Configure STT/TTS services

### Step 3: Test

1. Say the wake word (default: "Okay Nabu")
2. Speak your command
3. Reachy Mini should respond with motion and voice

## Project Structure

```
reachy_mini_ha_voice/
β”œβ”€β”€ src/
β”‚   └── reachy_mini_ha_voice/
β”‚       β”œβ”€β”€ __init__.py
β”‚       β”œβ”€β”€ main.py              # Entry point
β”‚       β”œβ”€β”€ app.py               # Main application
β”‚       β”œβ”€β”€ state.py             # State management
β”‚       β”œβ”€β”€ audio/               # Audio processing
β”‚       β”‚   β”œβ”€β”€ adapter.py       # Audio device adapter
β”‚       β”‚   └── processor.py     # Audio processor
β”‚       β”œβ”€β”€ voice/               # Voice processing
β”‚       β”‚   β”œβ”€β”€ detector.py      # Wake word detection
β”‚       β”‚   β”œβ”€β”€ stt.py           # STT (backup)
β”‚       β”‚   └── tts.py           # TTS (backup)
β”‚       β”œβ”€β”€ motion/              # Motion control
β”‚       β”‚   β”œβ”€β”€ controller.py    # Motion controller
β”‚       β”‚   └── queue.py         # Motion queue
β”‚       β”œβ”€β”€ esphome/             # ESPHome protocol
β”‚       β”‚   β”œβ”€β”€ protocol.py      # Protocol definitions
β”‚       β”‚   └── server.py        # ESPHome server
β”‚       └── config/              # Configuration
β”‚           └── manager.py        # Config manager
β”œβ”€β”€ profiles/                    # Personality profiles
β”‚   └── default/
β”œβ”€β”€ wakewords/                   # Wake word models
β”œβ”€β”€ pyproject.toml               # Project config
β”œβ”€β”€ PROJECT_PLAN.md              # Project plan
β”œβ”€β”€ ARCHITECTURE.md              # Architecture docs
β”œβ”€β”€ REQUIREMENTS.md              # Requirements
└── README.md                    # This file
```

## Development

### Running Tests

```bash
# Install development dependencies
pip install -e .[dev]

# Run tests
pytest

# Run with coverage
pytest --cov=reachy_mini_ha_voice
```

### Code Style

```bash
# Format code
ruff format .

# Lint code
ruff check .
```

## Documentation

- [Project Plan](PROJECT_PLAN.md) - Detailed project plan
- [Architecture](ARCHITECTURE.md) - System architecture and design
- [Requirements](REQUIREMENTS.md) - Functional and technical requirements

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

## Acknowledgments

- [OHF-Voice/linux-voice-assistant](https://github.com/OHF-Voice/linux-voice-assistant) - Original project
- [Pollen Robotics](https://www.pollen-robotics.com/) - Reachy Mini robot
- [Hugging Face](https://huggingface.co/) - Platform and tools

## Support

For issues and questions:
- Open an issue on GitHub
- Join the Discord community
- Check the documentation

---

Made with ❀️ for Reachy Mini and Home Assistant community