gavanduffy commited on
Commit
052919a
·
1 Parent(s): 77af671

Add HF Space YAML metadata

Browse files
Files changed (1) hide show
  1. README.md +44 -271
README.md CHANGED
@@ -1,109 +1,56 @@
1
- # PocketTTS OpenAI-Compatible Server
 
 
 
 
 
 
 
 
2
 
3
- An OpenAI-compatible Text-to-Speech API server powered by [Pocket-TTS](https://github.com/kyutai-labs/pocket-tts). Drop-in replacement for OpenAI's TTS API with support for streaming, custom voices, and voice cloning.
4
 
5
- Tested and working fully with [WingmanAI by Shipbit](https://www.wingman-ai.com/). Due to low resource use, can be used for real time local text to speech even while playing intensive video games (even in VR!) with WingmanAI.
6
 
7
  **Key Features:**
8
 
9
- - 🎯 **OpenAI API Compatible** - Works with any OpenAI TTS client
10
- - 🚀 **Real-time Streaming** - Low-latency audio generation
11
- - 🎤 **150+ Community Voices** - Ready-to-use voice library included
12
- - 🎭 **Voice Cloning** - Clone any voice from a short audio sample
13
- - 🐳 **Docker Ready** - One-command deployment
14
- - 💻 **Cross-platform** - Runs on Windows, macOS, and Linux
15
- - ⚡ **CPU Optimized** - No GPU required
16
- - 🎤 **Text pre-processing** - Clean text for words and symbols TTS usually has difficulty with, automatically
17
 
18
  ## Quick Start
19
 
20
- ### Option 1: Docker (Recommended)
21
 
22
  ```bash
23
- # Clone the repository
24
- git clone https://github.com/teddybear082/pocket-tts-openai_streaming_server.git
25
- cd pocket-tts-openai_streaming_server
26
-
27
- # Start the server
28
  docker compose up -d
29
-
30
- # View logs
31
- docker compose logs -f
32
  ```
33
 
34
- The server will be available at `http://localhost:49112`
35
 
36
- **Custom Configuration:**
37
 
38
  ```bash
39
- # Change port
40
- POCKET_TTS_PORT=8080 docker compose up -d
41
-
42
- # Use custom voices directory
43
- POCKET_TTS_VOICES_DIR=/path/to/my/voices docker compose up -d
44
- ```
45
-
46
- ### Option 2: Python (from source)
47
-
48
- ```bash
49
- # Clone the repository
50
- git clone https://github.com/teddybear082/pocket-tts-openai_streaming_server.git
51
- cd pocket-tts-openai_streaming_server
52
-
53
- # Create virtual environment
54
  python -m venv venv
55
- source venv/bin/activate # On Windows: venv\Scripts\activate
56
-
57
- # Install dependencies
58
  pip install -r requirements.txt
59
-
60
- # Start the server
61
  python server.py
62
  ```
63
 
64
- **Command Line Options:**
65
-
66
- ```bash
67
- python server.py --help
68
-
69
- # Custom port and voices
70
- python server.py --port 8080 --voices-dir ./my_voices
71
-
72
- # Enable streaming by default
73
- python server.py --stream
74
-
75
- # Enable text preprocessing
76
- python server.py --text-preprocess
77
- ```
78
-
79
- ### Option 3: Windows Executable
80
-
81
- 1. Download the latest release from [Releases](https://github.com/teddybear082/pocket-tts-openai_streaming_server/releases)
82
- 2. Extract the ZIP file
83
- 3. Double-click `PocketTTS-Server.exe` to run with defaults
84
- 4. Or run `run_pocket_tts_server_exe.bat` for custom configuration
85
-
86
- ## Web Interface
87
-
88
- Open `http://localhost:49112` in your browser to access the built-in web UI:
89
-
90
- - Select from available voices
91
- - Enter text to synthesize
92
- - Listen to generated audio directly
93
-
94
  ## API Usage
95
 
96
  ### Generate Speech
97
 
98
- **Endpoint:** `POST /v1/audio/speech`
99
-
100
  ```bash
101
- curl http://localhost:49112/v1/audio/speech \
102
  -H "Content-Type: application/json" \
103
  -d '{
104
  "model": "tts-1",
105
- "input": "Hello world! This is a test.",
106
- "voice": "alba"
107
  }' \
108
  --output speech.mp3
109
  ```
@@ -114,211 +61,37 @@ curl http://localhost:49112/v1/audio/speech \
114
  from openai import OpenAI
115
 
116
  client = OpenAI(
117
- base_url="http://localhost:49112/v1",
118
- api_key="not-needed" # No authentication required
119
  )
120
 
121
- # Generate and save audio
122
  response = client.audio.speech.create(
123
  model="tts-1",
124
- voice="alba",
125
- input="Hello world! This is a test."
126
  )
127
  response.stream_to_file("output.mp3")
128
-
129
- # Streaming
130
- with client.audio.speech.with_streaming_response.create(
131
- model="tts-1",
132
- voice="alba",
133
- input="This is streaming audio.",
134
- response_format="pcm"
135
- ) as response:
136
- for chunk in response.iter_bytes():
137
- # Process audio chunks in real-time
138
- pass
139
  ```
140
 
141
- ### API Reference
142
-
143
- | Endpoint | Method | Description |
144
- | ------------------ | ------ | ---------------------------------------- |
145
- | `/` | GET | Web interface |
146
- | `/health` | GET | Health check for container orchestration |
147
- | `/v1/voices` | GET | List available voices |
148
- | `/v1/audio/speech` | POST | Generate speech audio |
149
-
150
- **Speech Parameters:**
151
-
152
- | Parameter | Type | Required | Default | Description |
153
- | ----------------- | ------- | -------- | ------- | -------------------------------------------------- |
154
- | `model` | string | No | - | Ignored (for OpenAI compatibility) |
155
- | `input` | string | Yes | - | Text to synthesize |
156
- | `voice` | string | No | `alba` | Voice ID (see `/v1/voices`) |
157
- | `response_format` | string | No | `mp3` | Output format: `mp3`, `wav`, `pcm`, `opus`, `aac`, `flac` |
158
- | `stream` | boolean | No | `false` | Enable streaming response |
159
-
160
- ## Custom Voices
161
-
162
- ### Using Custom Voice Files
163
-
164
- 1. **Create a voices directory** with your audio files (`.wav`, `.mp3`, `.flac`)
165
- 2. **Configure the server** to use your directory:
166
 
167
- **Docker:**
 
 
 
 
 
 
168
 
169
- ```bash
170
- POCKET_TTS_VOICES_DIR=/path/to/voices docker compose up -d
171
- ```
172
 
173
- **Python:**
174
-
175
- ```bash
176
- python server.py --voices-dir /path/to/voices
177
- ```
178
-
179
- **Windows EXE:**
180
- Use the batch launcher and specify the voices directory when prompted.
181
-
182
- 3. **Use your voice** by filename:
183
- ```json
184
- { "voice": "my_voice.wav", "input": "Hello!" }
185
- ```
186
-
187
- ### Voice File Guidelines
188
-
189
- - **Duration:** 3-15 seconds of clear speech works best
190
- - **Quality:** Clean audio without background noise
191
- - **Format:** WAV, MP3, or FLAC
192
- - **Tip:** Use [Adobe Podcast Enhance](https://podcast.adobe.com/enhance) to clean noisy samples
193
-
194
- ### Built-in Voices
195
-
196
- The following voices are available by default:
197
- `alba`, `marius`, `javert`, `jean`, `fantine`, `cosette`, `eponine`, `azelma`
198
-
199
- The `voices/` directory includes 150+ community-contributed voices.
200
 
201
  ## Configuration
202
 
203
- ### Environment Variables
204
-
205
- | Variable | Default | Description |
206
- | ------------------------------------| ---------- | -------------------------------------- |
207
- | `POCKET_TTS_HOST` | `0.0.0.0` | Server bind address |
208
- | `POCKET_TTS_PORT` | `49112` | Server port |
209
- | `POCKET_TTS_VOICES_DIR` | `./voices` | Custom voices directory |
210
- | `POCKET_TTS_MODEL_PATH` | - | Custom model path |
211
- | `POCKET_TTS_STREAM_DEFAULT` | `true` | Enable streaming by default |
212
- | `POCKET_TTS_TEXT_PREPROCESS_DEFAULT`| `true` | Enable text preprocessing by default |
213
- | `POCKET_TTS_LOG_LEVEL` | `INFO` | Log level: DEBUG, INFO, WARNING, ERROR |
214
- | `POCKET_TTS_LOG_DIR` | `./logs` | Log files directory |
215
- | `HF_TOKEN` | - | Hugging Face token (for voice cloning) |
216
-
217
- ### Docker Compose Options
218
-
219
- See [docker-compose.yml](docker-compose.yml) for all available options including:
220
-
221
- - Volume mounts for custom voices
222
- - Resource limits
223
- - Health check configuration
224
- - HuggingFace cache persistence
225
-
226
- ## Project Structure
227
-
228
- ```
229
- pocket-tts-openai_streaming_server/
230
- ├── app/ # Application modules
231
- │ ├── __init__.py # Flask app factory
232
- │ ├── config.py # Configuration management
233
- │ ├── logging_config.py # Logging setup
234
- │ ├── routes.py # API endpoints
235
- │ └── services/ # Business logic
236
- │ ├── audio.py # Audio conversion
237
- │ └── tts.py # TTS service
238
- | |-- preprocess.py # Text preprocessor
239
- ├── static/ # Web UI assets
240
- ├── templates/ # HTML templates
241
- ├── voices/ # Voice files
242
- ├── server.py # Main entry point
243
- ├── Dockerfile # Container build
244
- ├── docker-compose.yml # Container orchestration
245
- └── requirements.txt # Python dependencies
246
- ```
247
-
248
- ## Development
249
-
250
- ### Dependencies
251
-
252
- | File | Purpose |
253
- | ---------------------- | ---------------------------------------------------- |
254
- | `requirements.txt` | Runtime dependencies only (Flask, torch, pocket-tts) |
255
- | `requirements-dev.txt` | Adds dev tools: ruff (linting), pytest (testing) |
256
-
257
- ### Running Locally
258
-
259
- ```bash
260
- # Install runtime dependencies only
261
- pip install -r requirements.txt
262
-
263
- # Or install with dev tools (recommended for contributors)
264
- pip install -r requirements-dev.txt
265
-
266
- # Run with debug logging
267
- python server.py --log-level DEBUG
268
- ```
269
-
270
- ### Linting
271
-
272
- ```bash
273
- pip install ruff
274
- ruff check .
275
- ruff format .
276
- ```
277
-
278
- ### Building Windows EXE
279
-
280
- ```bash
281
- pip install pyinstaller
282
- pyinstaller --onefile --name PocketTTS-Server \
283
- --add-data "static;static" \
284
- --add-data "templates;templates" \
285
- --add-data "voices;voices" \
286
- --add-data "app;app" \
287
- server.py
288
- ```
289
-
290
- ## Troubleshooting
291
-
292
- ### Model Loading Takes Long
293
-
294
- First run downloads the model (~500MB). Subsequent runs use cached model.
295
-
296
- **Docker:** Model cache is persisted in a Docker volume.
297
-
298
- ### Voice Cloning Requires HF Token
299
-
300
- For voice cloning, you may need a Hugging Face token:
301
-
302
- 1. Get token from https://huggingface.co/settings/tokens
303
- 2. Set `HF_TOKEN` environment variable
304
-
305
- ### Port Already in Use
306
-
307
- ```bash
308
- # Use a different port
309
- python server.py --port 8080
310
-
311
- # Or with Docker
312
- POCKET_TTS_PORT=8080 docker compose up -d
313
- ```
314
-
315
- ## Credits
316
-
317
- - [Pocket-TTS](https://github.com/kyutai-labs/pocket-tts) by Kyutai Labs
318
- - Community voice contributors (see [voices/credits.txt](voices/credits.txt))
319
-
320
- ## License
321
-
322
- This project is licensed under the MIT License - see [LICENSE](LICENSE) for details.
323
-
324
- Pocket-TTS is subject to its own license terms.
 
1
+ ---
2
+ title: SuperTonic3 TTS API
3
+ emoji: 🎤
4
+ colorFrom: blue
5
+ colorTo: purple
6
+ sdk: docker
7
+ pinned: false
8
+ license: mit
9
+ ---
10
 
11
+ # SuperTonic3 TTS API
12
 
13
+ OpenAI-compatible Text-to-Speech API server powered by [supertonic3](https://github.com/nicegram/nicegram-android) (ONNX-based). Drop-in replacement for OpenAI's TTS API with 31 languages and 10 built-in voices.
14
 
15
  **Key Features:**
16
 
17
+ - **OpenAI API Compatible** - Works with any OpenAI TTS client
18
+ - **31 Languages** - Single model supports 31 languages
19
+ - **10 Built-in Voices** - M1-M5 (male), F1-F5 (female)
20
+ - **CPU Optimized** - No GPU required (ONNX runtime)
21
+ - **44100 Hz Output** - High-quality audio
22
+ - **Docker Ready** - One-command deployment
 
 
23
 
24
  ## Quick Start
25
 
26
+ ### Docker
27
 
28
  ```bash
 
 
 
 
 
29
  docker compose up -d
 
 
 
30
  ```
31
 
32
+ Server available at `http://localhost:7860`
33
 
34
+ ### Python
35
 
36
  ```bash
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  python -m venv venv
38
+ source venv/bin/activate
 
 
39
  pip install -r requirements.txt
 
 
40
  python server.py
41
  ```
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  ## API Usage
44
 
45
  ### Generate Speech
46
 
 
 
47
  ```bash
48
+ curl -X POST http://localhost:7860/v1/audio/speech \
49
  -H "Content-Type: application/json" \
50
  -d '{
51
  "model": "tts-1",
52
+ "input": "Hello world!",
53
+ "voice": "M1"
54
  }' \
55
  --output speech.mp3
56
  ```
 
61
  from openai import OpenAI
62
 
63
  client = OpenAI(
64
+ base_url="http://localhost:7860/v1",
65
+ api_key="not-needed"
66
  )
67
 
 
68
  response = client.audio.speech.create(
69
  model="tts-1",
70
+ voice="M1",
71
+ input="Hello world!"
72
  )
73
  response.stream_to_file("output.mp3")
 
 
 
 
 
 
 
 
 
 
 
74
  ```
75
 
76
+ ### Speech Parameters
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
78
+ | Parameter | Type | Required | Default | Description |
79
+ | ----------------- | ------- | -------- | ------- | --------------------------------- |
80
+ | `input` | string | Yes | - | Text to synthesize |
81
+ | `voice` | string | No | `M1` | Voice: M1-M5, F1-F5 |
82
+ | `response_format` | string | No | `mp3` | Output: `mp3`, `wav`, `flac` |
83
+ | `lang` | string | No | `en` | Language code (31 supported) |
84
+ | `stream` | boolean | No | `false` | Enable streaming |
85
 
86
+ ### Languages
 
 
87
 
88
+ 31 supported languages: en, zh, ja, ko, fr, de, es, it, pt, ru, ar, hi, bn, id, ms, th, vi, tl, tr, fa, pl, nl, sv, da, fi, cs, ro, hu, el, he, uk
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
  ## Configuration
91
 
92
+ | Environment Variable | Default | Description |
93
+ | ----------------------------------- | ---------- | ----------------- |
94
+ | `SUPERTONIC3_HOST` | `0.0.0.0` | Bind address |
95
+ | `SUPERTONIC3_PORT` | `7860` | Port |
96
+ | `SUPERTONIC3_VOICE` | `M1` | Default voice |
97
+ | `SUPERTONIC3_LOG_LEVEL` | `INFO` | Log level |