A minimal FastAPI server responsible for playing WAV audio via aplay. Runs on a host with a connected speaker (Raspberry Pi / any Linux with ALSA). Called by the Homemade Alexa Server after a TTS response is generated.
- Python 3
aplay(from thealsa-utilspackage)- Configured ALSA audio output
pip install -r requirements.txt
./run.shThe server starts on 0.0.0.0:1234.
The server address is configured on the Alexa Server side in config.toml:
[audio_server]
url = "http://YOUR_AUDIO_SERVER_IP:1234"| Method | Path | Description |
|---|---|---|
POST |
/api/play |
Body: raw WAV bytes; starts playback via aplay; returns immediately with {"status": "playing"} |
POST |
/api/abort |
Stops current playback (SIGKILL on aplay); returns {"status": "aborted"} or {"status": "nothing_playing"} |
- Playback runs in a separate thread — the server responds immediately without blocking subsequent requests.
- Calling
/api/playwhile playback is already in progress kills the currentaplayprocess before starting a new one. /api/abortis called by the Alexa Server when the ESP32 device detects a wake word during response playback.