44 lines
1.1 KiB
Markdown
44 lines
1.1 KiB
Markdown
|
|
# piper-openai-proxy
|
||
|
|
|
||
|
|
OpenAI-compatible TTS API proxy for [Piper](https://github.com/rhasspy/piper) via the [Wyoming protocol](https://github.com/rhasspy/wyoming).
|
||
|
|
|
||
|
|
Any tool that speaks the OpenAI `/v1/audio/speech` API can use your local Piper instance without modification.
|
||
|
|
|
||
|
|
## Usage
|
||
|
|
|
||
|
|
```bash
|
||
|
|
python3 server.py
|
||
|
|
```
|
||
|
|
|
||
|
|
Environment variables:
|
||
|
|
- `PIPER_HOST` — Piper Wyoming host (default: `192.168.86.11`)
|
||
|
|
- `PIPER_PORT` — Piper Wyoming port (default: `10200`)
|
||
|
|
- `LISTEN_PORT` — Proxy listen port (default: `8951`)
|
||
|
|
|
||
|
|
## API
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Generate speech
|
||
|
|
curl -X POST http://localhost:8951/v1/audio/speech \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d '{"input": "Hello world"}' \
|
||
|
|
-o speech.wav
|
||
|
|
|
||
|
|
# Health check
|
||
|
|
curl http://localhost:8951/health
|
||
|
|
```
|
||
|
|
|
||
|
|
## Requirements
|
||
|
|
|
||
|
|
- Python 3.8+
|
||
|
|
- No dependencies (stdlib only)
|
||
|
|
- A running [Piper Wyoming server](https://github.com/rhasspy/wyoming-piper)
|
||
|
|
|
||
|
|
## How it works
|
||
|
|
|
||
|
|
The proxy translates OpenAI TTS API requests into Wyoming protocol messages over a raw TCP socket. Piper generates the audio, and the proxy wraps the raw PCM in a WAV container and returns it.
|
||
|
|
|
||
|
|
## License
|
||
|
|
|
||
|
|
MIT
|