Update README.md
Browse files
README.md
CHANGED
|
@@ -5,209 +5,192 @@ license: apache-2.0
|
|
| 5 |
library_name: transformers
|
| 6 |
datasets: proprietary
|
| 7 |
tags:
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
-
|
| 11 |
-
- voice-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
pipeline_tag: text-to-speech
|
| 13 |
---
|
| 14 |
|
| 15 |
-
#
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
**The problem:** Traditional TTS struggles with three things—you can't reliably control voice characteristics without per-speaker training, streaming kills quality, and reproducing the same voice twice is inconsistent.
|
| 28 |
-
|
| 29 |
-
**What we built:** Declarative voice design through XML attributes. The model maps text descriptions to delivery. Add inline emotion tags (`<laugh>`, `<angry>`, and even `<sings>`, more explained below) for moment-level control without breaking persona. SNAC's low-bitrate tokens enable real-time generation with stable quality. Works with vLLM for production deployment.
|
| 30 |
-
|
| 31 |
-
## Model Details
|
| 32 |
-
|
| 33 |
-
### Architecture
|
| 34 |
-
|
| 35 |
-
We pretrained and finetuned a 3B-parameter decoder-only transformer (Llama-style) that predicts **SNAC codec tokens** instead of waveforms.
|
| 36 |
-
|
| 37 |
-
**The flow:** `<description="..."> text` → tokenize → generate SNAC codes (7 tokens/frame) → decode → 24 kHz audio. Emotion tags like `<laugh>` and `<sigh>` are special tokens placed exactly where needed.
|
| 38 |
-
|
| 39 |
-
**Why this works:** Discrete codecs let the model focus on delivery rather than raw acoustics. SNAC's hierarchical structure (≈12/23/47 Hz) keeps sequences compact for lower latency and stable long-form generation. Runs on standard LLM infrastructure (vLLM), making streaming trivial.
|
| 40 |
-
|
| 41 |
-
### Preprocessing
|
| 42 |
-
|
| 43 |
-
We built a multi-gate pipeline that standardized everything before training.
|
| 44 |
-
|
| 45 |
-
1. **Acoustic standardization** - Resample to 24 kHz mono. Normalize loudness to -23 LUFS. Trim silence with VAD. Enforce 1-14s clip lengths.
|
| 46 |
-
2. **Text alignment** - Forced alignment (MFA) at sentence level for clean boundaries. Unicode normalization, number expansion, punctuation cleanup.
|
| 47 |
-
3. **Emotion tagging** - Map all stage directions to a closed set of special tokens (`<laugh>`, `<whisper>`). Each tag is 1 token.
|
| 48 |
-
4. **Deduplication** - MinHash/LSH for text near-dupes. Chromaprint for audio duplicates.
|
| 49 |
-
5. **Codec prep** - SNAC encode at 24 kHz, pack into 7-token frames, discard partials.
|
| 50 |
-
6. **Labeling** - Mask description text in loss (conditioning only). Keep emotion tags unmasked (control signals).
|
| 51 |
-
7. **QC** - Speaker-disjoint splits. Automated checks for LUFS, SNR, alignment confidence, per-tag coverage.
|
| 52 |
-
|
| 53 |
-
**Why it mattered:** Consistent acoustics = consistent tokens = clean learning. No dupes = faster convergence. Clean boundaries = stable prosody.
|
| 54 |
-
|
| 55 |
-

|
| 56 |
-
*Mimi adversarial reference codec*
|
| 57 |
-
|
| 58 |
-
## Training Data
|
| 59 |
-
|
| 60 |
-
### Data Sourcing & Labeling
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
|
| 66 |
-
**
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
**
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
- Forced alignment (MFA) for clean phrase boundaries
|
| 73 |
-
- Removing Dedup Frames (MinHash-LSH), audio dedup (Chromaprint)
|
| 74 |
-
- SNAC encode at 24 kHz, pack 7-token frames, drop partials
|
| 75 |
|
| 76 |
-
**
|
| 77 |
|
| 78 |
-
|
| 79 |
|
| 80 |
-
|
| 81 |
|
| 82 |
-
###
|
| 83 |
|
|
|
|
| 84 |
```
|
| 85 |
-
|
| 86 |
```
|
| 87 |
|
| 88 |
-
**
|
| 89 |
-
|
| 90 |
-
### (2) Angle-list attributes
|
| 91 |
-
|
| 92 |
```
|
| 93 |
-
|
| 94 |
```
|
| 95 |
|
| 96 |
-
**
|
| 97 |
-
|
| 98 |
-
### (3) Typed key-value tags
|
| 99 |
|
| 100 |
-
|
| 101 |
-
<age=40><pitch=low><timbre=warm> {text}
|
| 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 |
-
<description="
|
| 136 |
```
|
| 137 |
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
**Examples:**
|
| 141 |
|
|
|
|
|
|
|
| 142 |
```
|
| 143 |
-
<description="35-yr old, low pitch, warm, conversational, product demo">
|
| 144 |
Our new update <laugh> finally ships with the feature you asked for.
|
| 145 |
```
|
| 146 |
|
| 147 |
-
|
| 148 |
-
<description="event host, energetic, clear diction, slight NY accent">
|
| 149 |
-
Please welcome our next speaker <sigh> who needs no introduction.
|
| 150 |
-
```
|
| 151 |
-
|
| 152 |
-
```
|
| 153 |
-
<description="dark villain, breathy, slow, ominous">
|
| 154 |
-
You thought the night would hide you <whisper> but the night is mine.
|
| 155 |
-
```
|
| 156 |
-
|
| 157 |
-
**Guidelines:**
|
| 158 |
-
- Write like you'd brief a voice actor. Use commas.
|
| 159 |
-
- Place emotions exactly where they happen.
|
| 160 |
-
- Don't nest quotes inside descriptions.
|
| 161 |
-
- Stay consistent with format—consistency = stable persona.
|
| 162 |
-
|
| 163 |
-
### Available Emotions
|
| 164 |
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
### Inference & vLLM
|
| 172 |
-
|
| 173 |
-
**Setup:**
|
| 174 |
|
| 175 |
-
|
| 176 |
-
2. Decode with SNAC 24 kHz to PCM.
|
| 177 |
-
3. Enable Automatic Prefix Caching (APC) in vLLM for reused descriptors—it caches KV for identical prefixes.
|
| 178 |
-
4. Set stop to audio EOS only via `stop_token_ids`.
|
| 179 |
-
5. For web playback, use WebAudio (AudioWorklet) with ring buffer—avoids underruns and clicks.
|
| 180 |
|
| 181 |
-
|
| 182 |
|
| 183 |
```python
|
| 184 |
import torch
|
| 185 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 186 |
from snac import SNAC
|
| 187 |
-
import
|
| 188 |
|
| 189 |
-
# Load
|
| 190 |
-
model = AutoModelForCausalLM.from_pretrained(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
tokenizer = AutoTokenizer.from_pretrained("maya-research/maya-1-voice")
|
| 192 |
|
| 193 |
-
# Load SNAC decoder (24kHz)
|
| 194 |
snac_model = SNAC.from_pretrained("hubertsiuzdak/snac_24khz").eval().to("cuda")
|
| 195 |
|
| 196 |
-
#
|
| 197 |
description = "Realistic male voice in the 30s age with american accent. Normal pitch, warm timbre, conversational pacing."
|
| 198 |
-
text = "Hello! This is Maya-1-Voice
|
|
|
|
|
|
|
| 199 |
prompt = f'<description="{description}"> {text}'
|
| 200 |
|
| 201 |
-
# Generate
|
| 202 |
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 203 |
with torch.inference_mode():
|
| 204 |
-
outputs = model.generate(
|
| 205 |
-
|
| 206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
generated_ids = outputs[0, inputs['input_ids'].shape[1]:]
|
| 208 |
snac_tokens = [t.item() for t in generated_ids if 128266 <= t <= 156937]
|
| 209 |
|
| 210 |
-
# Decode to audio
|
| 211 |
frames = len(snac_tokens) // 7
|
| 212 |
codes = [[], [], []]
|
| 213 |
for i in range(frames):
|
|
@@ -216,145 +199,218 @@ for i in range(frames):
|
|
| 216 |
codes[1].extend([(s[1]-128266) % 4096, (s[4]-128266) % 4096])
|
| 217 |
codes[2].extend([(s[2]-128266) % 4096, (s[3]-128266) % 4096, (s[5]-128266) % 4096, (s[6]-128266) % 4096])
|
| 218 |
|
| 219 |
-
#
|
| 220 |
codes_tensor = [torch.tensor(c, dtype=torch.long, device="cuda").unsqueeze(0) for c in codes]
|
| 221 |
with torch.inference_mode():
|
| 222 |
audio = snac_model.decoder(snac_model.quantizer.from_codes(codes_tensor))[0, 0].cpu().numpy()
|
| 223 |
|
| 224 |
-
# Save
|
| 225 |
-
import soundfile as sf
|
| 226 |
sf.write("output.wav", audio, 24000)
|
|
|
|
| 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 |
-
<description="Female, in her 30s with an American accent and is an event host, energetic, clear diction, ">
|
| 270 |
-
```
|
| 271 |
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
Wow. This place looks even better than I imagined. How did they set all this up so perfectly? The lights, the music, everything feels magical. I can't stop smiling right now.
|
| 275 |
-
```
|
| 276 |
|
| 277 |
-
|
|
|
|
| 278 |
|
|
|
|
|
|
|
| 279 |
|
| 280 |
-
|
|
|
|
| 281 |
|
|
|
|
|
|
|
| 282 |
|
| 283 |
---
|
| 284 |
|
| 285 |
-
|
| 286 |
|
| 287 |
-
**
|
| 288 |
-
|
| 289 |
-
<description="Dark villain character, Male voice in their 40s with a British accent. low pitch, gravelly timbre, slow pacing, angry tone at high intensity.">
|
| 290 |
-
```
|
| 291 |
|
| 292 |
-
**
|
| 293 |
-
|
| 294 |
-
Welcome back to another episode of our podcast! <laugh_harder> Today we are diving into an absolutely fascinating topic
|
| 295 |
-
```
|
| 296 |
|
| 297 |
-
**
|
|
|
|
| 298 |
|
|
|
|
|
|
|
| 299 |
|
| 300 |
-
|
|
|
|
| 301 |
|
| 302 |
-
|
|
|
|
| 303 |
|
| 304 |
-
|
|
|
|
| 305 |
|
| 306 |
-
|
| 307 |
-
```
|
| 308 |
-
<description="Demon character, Male voice in their 30s with a Middle Eastern accent. screaming tone at high intensity. ">
|
| 309 |
-
```
|
| 310 |
|
| 311 |
-
|
| 312 |
-
```
|
| 313 |
-
You dare challenge me, mortal <snort> how amusing. Your kind always thinks they can win
|
| 314 |
-
```
|
| 315 |
|
| 316 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
|
|
|
|
| 318 |
|
| 319 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 320 |
|
| 321 |
---
|
| 322 |
|
| 323 |
-
|
| 324 |
|
| 325 |
-
|
| 326 |
-
```
|
| 327 |
-
|
| 328 |
-
|
|
|
|
| 329 |
|
| 330 |
-
|
|
|
|
|
|
|
| 331 |
```
|
| 332 |
-
After all we went through to pull him out of that mess <cry> I can't believe he was the traitor
|
| 333 |
|
|
|
|
|
|
|
|
|
|
| 334 |
```
|
| 335 |
|
| 336 |
-
|
|
|
|
|
|
|
|
|
|
| 337 |
|
|
|
|
| 338 |
|
| 339 |
-
|
| 340 |
|
| 341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
|
|
|
|
| 344 |
|
|
|
|
| 345 |
|
| 346 |
-
|
| 347 |
|
|
|
|
| 348 |
|
| 349 |
-
|
| 350 |
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
|
| 355 |
---
|
| 356 |
|
| 357 |
-
**
|
| 358 |
-
|
| 359 |
-
**
|
| 360 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
library_name: transformers
|
| 6 |
datasets: proprietary
|
| 7 |
tags:
|
| 8 |
+
- best-voice-ai
|
| 9 |
+
- open-source-voice-ai
|
| 10 |
+
- text-to-speech-with-emotions
|
| 11 |
+
- voice-ai-model
|
| 12 |
+
- emotional-voice-synthesis
|
| 13 |
+
- voice-design-features
|
| 14 |
+
- english-voice-ai
|
| 15 |
+
- streaming-tts
|
| 16 |
+
- real-time-voice-generation
|
| 17 |
+
- indian-ai-research
|
| 18 |
+
- voice-cloning
|
| 19 |
+
- expressive-speech-synthesis
|
| 20 |
+
- multilingual-voice-ai
|
| 21 |
pipeline_tag: text-to-speech
|
| 22 |
---
|
| 23 |
|
| 24 |
+
# Maya-1-Voice
|
| 25 |
|
| 26 |
+
**Maya-1-Voice** is an open source voice AI model for English with voice design and 20+ human emotions.
|
| 27 |
|
| 28 |
+
State-of-the-art from the open source community. Production-ready.
|
| 29 |
|
| 30 |
+
**What it does:**
|
| 31 |
+
- Voice design through natural language descriptions
|
| 32 |
+
- 20+ emotions: laugh, cry, whisper, angry, sigh, gasp, and more
|
| 33 |
+
- Real-time streaming with SNAC neural codec
|
| 34 |
+
- 3B parameters, runs on single GPU
|
| 35 |
+
- Apache 2.0 license
|
| 36 |
|
| 37 |
+
Developed by Maya Research. Backed by South Park Commons.
|
| 38 |
|
| 39 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
## Demos
|
| 42 |
|
| 43 |
+
### Example 1: Energetic Female Event Host
|
| 44 |
|
| 45 |
+
**Voice Description:**
|
| 46 |
+
```
|
| 47 |
+
Female, in her 30s with an American accent and is an event host, energetic, clear diction
|
| 48 |
+
```
|
| 49 |
|
| 50 |
+
**Text:**
|
| 51 |
+
```
|
| 52 |
+
Wow. This place looks even better than I imagined. How did they set all this up so perfectly? The lights, the music, everything feels magical. I can't stop smiling right now.
|
| 53 |
+
```
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
**Audio Output:**
|
| 56 |
|
| 57 |
+
<audio controls src="https://cdn-uploads.huggingface.co/production/uploads/642a7d4e556ab448a0701ca1/4zDlBLeFk0Y2rOrQhMW9r.wav"></audio>
|
| 58 |
|
| 59 |
+
---
|
| 60 |
|
| 61 |
+
### Example 2: Dark Villain with Anger
|
| 62 |
|
| 63 |
+
**Voice Description:**
|
| 64 |
```
|
| 65 |
+
Dark villain character, Male voice in their 40s with a British accent. low pitch, gravelly timbre, slow pacing, angry tone at high intensity.
|
| 66 |
```
|
| 67 |
|
| 68 |
+
**Text:**
|
|
|
|
|
|
|
|
|
|
| 69 |
```
|
| 70 |
+
Welcome back to another episode of our podcast! <laugh_harder> Today we are diving into an absolutely fascinating topic
|
| 71 |
```
|
| 72 |
|
| 73 |
+
**Audio Output:**
|
|
|
|
|
|
|
| 74 |
|
| 75 |
+
<audio controls src="https://cdn-uploads.huggingface.co/production/uploads/642a7d4e556ab448a0701ca1/mT6FnTrA3KYQnwfJms92X.wav"></audio>
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
---
|
| 78 |
|
| 79 |
+
### Example 3: Demon Character (Screaming Emotion)
|
| 80 |
|
| 81 |
+
**Voice Description:**
|
| 82 |
```
|
| 83 |
+
Demon character, Male voice in their 30s with a Middle Eastern accent. screaming tone at high intensity.
|
| 84 |
```
|
| 85 |
|
| 86 |
+
**Text:**
|
| 87 |
+
```
|
| 88 |
+
You dare challenge me, mortal <snort> how amusing. Your kind always thinks they can win
|
| 89 |
+
```
|
| 90 |
|
| 91 |
+
**Audio Output:**
|
| 92 |
|
| 93 |
+
<audio controls src="https://cdn-uploads.huggingface.co/production/uploads/642a7d4e556ab448a0701ca1/oxdns7uACCmLyC-P4H30G.wav"></audio>
|
| 94 |
|
| 95 |
+
---
|
| 96 |
|
| 97 |
+
### Example 4: Mythical Goddess with Crying Emotion
|
| 98 |
|
| 99 |
+
**Voice Description:**
|
| 100 |
+
```
|
| 101 |
+
Mythical godlike magical character, Female voice in their 30s slow pacing, curious tone at medium intensity.
|
| 102 |
+
```
|
| 103 |
|
| 104 |
+
**Text:**
|
| 105 |
+
```
|
| 106 |
+
After all we went through to pull him out of that mess <cry> I can't believe he was the traitor
|
| 107 |
+
```
|
| 108 |
|
| 109 |
+
**Audio Output:**
|
| 110 |
|
| 111 |
+
<audio controls src="https://cdn-uploads.huggingface.co/production/uploads/642a7d4e556ab448a0701ca1/ggzAhM-rEUyv_mPLSALQG.wav"></audio>
|
| 112 |
|
| 113 |
+
---
|
| 114 |
|
| 115 |
+
## Why Maya-1-Voice is Different: Voice Design Features That Matter
|
| 116 |
|
| 117 |
+
### 1. Natural Language Voice Control
|
| 118 |
+
Describe voices like you would brief a voice actor:
|
| 119 |
```
|
| 120 |
+
<description="40-year-old, warm, low pitch, conversational">
|
| 121 |
```
|
| 122 |
|
| 123 |
+
No complex parameters. No training data. Just describe and generate.
|
|
|
|
|
|
|
| 124 |
|
| 125 |
+
### 2. Inline Emotion Tags for Expressive Speech
|
| 126 |
+
Add emotions exactly where they belong in your text:
|
| 127 |
```
|
|
|
|
| 128 |
Our new update <laugh> finally ships with the feature you asked for.
|
| 129 |
```
|
| 130 |
|
| 131 |
+
**Supported Emotions:** `<laugh>` `<sigh>` `<whisper>` `<angry>` `<giggle>` `<chuckle>` `<gasp>` `<cry>` and 12+ more.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
+
### 3. Streaming Audio Generation
|
| 134 |
+
Real-time voice synthesis with SNAC neural codec (~0.98 kbps). Perfect for:
|
| 135 |
+
- Voice assistants
|
| 136 |
+
- Interactive AI agents
|
| 137 |
+
- Live content generation
|
| 138 |
+
- Game characters
|
| 139 |
+
- Podcasts and audiobooks
|
| 140 |
|
| 141 |
+
### 4. Production-Ready Infrastructure
|
| 142 |
+
- Runs on single GPU
|
| 143 |
+
- vLLM integration for scale
|
| 144 |
+
- Automatic prefix caching for efficiency
|
| 145 |
+
- 24 kHz audio output
|
| 146 |
+
- WebAudio compatible for browser playback
|
| 147 |
|
| 148 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
+
## How to Use Maya-1-Voice: Download and Run in Minutes
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
+
### Quick Start: Generate Voice with Emotions
|
| 153 |
|
| 154 |
```python
|
| 155 |
import torch
|
| 156 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 157 |
from snac import SNAC
|
| 158 |
+
import soundfile as sf
|
| 159 |
|
| 160 |
+
# Load the best open source voice AI model
|
| 161 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 162 |
+
"maya-research/maya-1-voice",
|
| 163 |
+
torch_dtype=torch.bfloat16,
|
| 164 |
+
device_map="auto"
|
| 165 |
+
)
|
| 166 |
tokenizer = AutoTokenizer.from_pretrained("maya-research/maya-1-voice")
|
| 167 |
|
| 168 |
+
# Load SNAC audio decoder (24kHz)
|
| 169 |
snac_model = SNAC.from_pretrained("hubertsiuzdak/snac_24khz").eval().to("cuda")
|
| 170 |
|
| 171 |
+
# Design your voice with natural language
|
| 172 |
description = "Realistic male voice in the 30s age with american accent. Normal pitch, warm timbre, conversational pacing."
|
| 173 |
+
text = "Hello! This is Maya-1-Voice <laugh> the best open source voice AI model with emotions."
|
| 174 |
+
|
| 175 |
+
# Create prompt with voice design
|
| 176 |
prompt = f'<description="{description}"> {text}'
|
| 177 |
|
| 178 |
+
# Generate emotional speech
|
| 179 |
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 180 |
with torch.inference_mode():
|
| 181 |
+
outputs = model.generate(
|
| 182 |
+
**inputs,
|
| 183 |
+
max_new_tokens=500,
|
| 184 |
+
temperature=0.4,
|
| 185 |
+
top_p=0.9,
|
| 186 |
+
do_sample=True
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
# Extract SNAC audio tokens
|
| 190 |
generated_ids = outputs[0, inputs['input_ids'].shape[1]:]
|
| 191 |
snac_tokens = [t.item() for t in generated_ids if 128266 <= t <= 156937]
|
| 192 |
|
| 193 |
+
# Decode SNAC tokens to audio frames
|
| 194 |
frames = len(snac_tokens) // 7
|
| 195 |
codes = [[], [], []]
|
| 196 |
for i in range(frames):
|
|
|
|
| 199 |
codes[1].extend([(s[1]-128266) % 4096, (s[4]-128266) % 4096])
|
| 200 |
codes[2].extend([(s[2]-128266) % 4096, (s[3]-128266) % 4096, (s[5]-128266) % 4096, (s[6]-128266) % 4096])
|
| 201 |
|
| 202 |
+
# Generate final audio with SNAC decoder
|
| 203 |
codes_tensor = [torch.tensor(c, dtype=torch.long, device="cuda").unsqueeze(0) for c in codes]
|
| 204 |
with torch.inference_mode():
|
| 205 |
audio = snac_model.decoder(snac_model.quantizer.from_codes(codes_tensor))[0, 0].cpu().numpy()
|
| 206 |
|
| 207 |
+
# Save your emotional voice output
|
|
|
|
| 208 |
sf.write("output.wav", audio, 24000)
|
| 209 |
+
print("✅ Voice generated successfully! Play output.wav")
|
| 210 |
```
|
| 211 |
|
| 212 |
+
### Advanced: Production Streaming with vLLM
|
| 213 |
|
| 214 |
+
For production deployments with real-time streaming, use our vLLM script:
|
| 215 |
|
| 216 |
+
**Download:** [vllm_streaming_inference.py](https://huggingface.co/maya-research/maya-1-voice/blob/main/vllm_streaming_inference.py)
|
| 217 |
|
| 218 |
+
**Key Features:**
|
| 219 |
+
- Automatic Prefix Caching (APC) for repeated voice descriptions
|
| 220 |
+
- WebAudio ring buffer integration
|
| 221 |
+
- Multi-GPU scaling support
|
| 222 |
+
- Sub-100ms latency for real-time applications
|
| 223 |
|
| 224 |
+
---
|
| 225 |
+
|
| 226 |
+
## Technical Excellence: What Makes Maya-1-Voice the Best
|
| 227 |
|
| 228 |
+
### Architecture: 3B-Parameter Llama Backbone for Voice
|
| 229 |
|
| 230 |
+
We pretrained a **3B-parameter decoder-only transformer** (Llama-style) to predict **SNAC neural codec tokens** instead of raw waveforms.
|
| 231 |
|
| 232 |
+
**The Flow:**
|
| 233 |
+
```
|
| 234 |
+
<description="..."> text → tokenize → generate SNAC codes (7 tokens/frame) → decode → 24 kHz audio
|
| 235 |
+
```
|
| 236 |
|
| 237 |
+
**Why SNAC?** Multi-scale hierarchical structure (≈12/23/47 Hz) keeps autoregressive sequences compact for real-time streaming at ~0.98 kbps.
|
| 238 |
|
| 239 |
+
### Training Data: What Makes Our Voice AI the Best
|
| 240 |
|
| 241 |
+
**Pretraining:** Internet-scale English speech corpus for broad acoustic coverage and natural coarticulation.
|
| 242 |
|
| 243 |
+
**Supervised Fine-Tuning:** Proprietary curated dataset of studio recordings with:
|
| 244 |
+
- Human-verified voice descriptions
|
| 245 |
+
- 20+ emotion tags per sample
|
| 246 |
+
- Multi-accent English coverage
|
| 247 |
+
- Character and role variations
|
| 248 |
|
| 249 |
+
**Data Pipeline Excellence:**
|
| 250 |
+
1. 24 kHz mono resampling with -23 LUFS normalization
|
| 251 |
+
2. VAD silence trimming with duration bounds (1-14s)
|
| 252 |
+
3. Forced alignment (MFA) for clean phrase boundaries
|
| 253 |
+
4. MinHash-LSH text deduplication
|
| 254 |
+
5. Chromaprint audio deduplication
|
| 255 |
+
6. SNAC encoding with 7-token frame packing
|
| 256 |
|
| 257 |
+
### Voice Design Experiments: Why Natural Language Won
|
| 258 |
|
| 259 |
+
We tested 4 conditioning formats. Only one delivered production-quality results:
|
| 260 |
+
|
| 261 |
+
**❌ Colon format:** `{description}: {text}` - Format drift, model spoke descriptions
|
| 262 |
+
|
| 263 |
+
**❌ Angle-list attributes:** `<{age}, {pitch}, {character}>` - Too rigid, poor generalization
|
| 264 |
+
|
| 265 |
+
**❌ Key-value tags:** `<age=40><pitch=low>` - Token bloat, brittle to mistakes
|
| 266 |
+
|
| 267 |
+
**✅ XML-attribute (WINNER):** `<description="40-yr old, low-pitch, warm">` - Natural language, robust, scalable
|
| 268 |
|
| 269 |
---
|
| 270 |
|
| 271 |
+
## Use Cases
|
| 272 |
|
| 273 |
+
### Game Character Voices
|
| 274 |
+
Generate unique character voices with emotions on-the-fly. No voice actor recording sessions.
|
|
|
|
|
|
|
| 275 |
|
| 276 |
+
### Podcast & Audiobook Production
|
| 277 |
+
Narrate content with emotional range and consistent personas across hours of audio.
|
|
|
|
|
|
|
| 278 |
|
| 279 |
+
### AI Voice Assistants
|
| 280 |
+
Build conversational agents with natural emotional responses in real-time.
|
| 281 |
|
| 282 |
+
### Video Content Creation
|
| 283 |
+
Create voiceovers for YouTube, TikTok, and social media with expressive delivery.
|
| 284 |
|
| 285 |
+
### Customer Service AI
|
| 286 |
+
Deploy empathetic voice bots that understand context and respond with appropriate emotions.
|
| 287 |
|
| 288 |
+
### Accessibility Tools
|
| 289 |
+
Build screen readers and assistive technologies with natural, engaging voices.
|
| 290 |
|
| 291 |
---
|
| 292 |
|
| 293 |
+
## Frequently Asked Questions
|
| 294 |
|
| 295 |
+
**Q: What makes Maya-1-Voice different?**
|
| 296 |
+
A: We're the only open source model offering 20+ emotions, zero-shot voice design, production-ready streaming, and 3B parameters—all in one package.
|
|
|
|
|
|
|
| 297 |
|
| 298 |
+
**Q: Can I use this commercially?**
|
| 299 |
+
A: Absolutely. Apache 2.0 license. Build products, deploy services, monetize freely.
|
|
|
|
|
|
|
| 300 |
|
| 301 |
+
**Q: What languages does it support?**
|
| 302 |
+
A: Currently English with multi-accent support. Future models will expand to languages and accents underserved by mainstream voice AI.
|
| 303 |
|
| 304 |
+
**Q: How does it compare to ElevenLabs, Murf.ai, or other closed-source tools?**
|
| 305 |
+
A: Feature parity with emotions and voice design. Advantage: you own the deployment, pay no per-second fees, and can customize the model.
|
| 306 |
|
| 307 |
+
**Q: Can I fine-tune on my own voices?**
|
| 308 |
+
A: Yes. The model architecture supports fine-tuning on custom datasets for specialized voices.
|
| 309 |
|
| 310 |
+
**Q: What GPU do I need?**
|
| 311 |
+
A: Single GPU with 16GB+ VRAM (A100, H100, or consumer RTX 4090).
|
| 312 |
|
| 313 |
+
**Q: Is streaming really real-time?**
|
| 314 |
+
A: Yes. SNAC codec enables sub-100ms latency with vLLM deployment.
|
| 315 |
|
| 316 |
+
---
|
|
|
|
|
|
|
|
|
|
| 317 |
|
| 318 |
+
## Comparison
|
|
|
|
|
|
|
|
|
|
| 319 |
|
| 320 |
+
| Feature | Maya-1-Voice | ElevenLabs | OpenAI TTS | Coqui TTS |
|
| 321 |
+
|---------|-------------|------------|------------|-----------|
|
| 322 |
+
| **Open Source** | Yes | No | No | Yes |
|
| 323 |
+
| **Emotions** | 20+ | Limited | No | No |
|
| 324 |
+
| **Voice Design** | Natural Language | Voice Library | Fixed | Complex |
|
| 325 |
+
| **Streaming** | Real-time | Yes | Yes | No |
|
| 326 |
+
| **Cost** | Free | Pay-per-use | Pay-per-use | Free |
|
| 327 |
+
| **Customization** | Full | Limited | None | Moderate |
|
| 328 |
+
| **Parameters** | 3B | Unknown | Unknown | <1B |
|
| 329 |
|
| 330 |
+
---
|
| 331 |
|
| 332 |
+
## Model Metadata
|
| 333 |
+
|
| 334 |
+
**Developed by:** Maya Research
|
| 335 |
+
**Website:** [mayaresearch.ai](https://mayaresearch.ai)
|
| 336 |
+
**Backed by:** South Park Commons
|
| 337 |
+
**Model Type:** Text-to-Speech, Emotional Voice Synthesis, Voice Design AI
|
| 338 |
+
**Language:** English (Multi-accent)
|
| 339 |
+
**Architecture:** 3B-parameter Llama-style transformer with SNAC codec
|
| 340 |
+
**License:** Apache 2.0 (Fully Open Source)
|
| 341 |
+
**Training Data:** Proprietary curated + Internet-scale pretraining
|
| 342 |
+
**Audio Quality:** 24 kHz, mono, ~0.98 kbps streaming
|
| 343 |
+
**Inference:** vLLM compatible, single GPU deployment
|
| 344 |
+
**Status:** Production-ready (December 2024)
|
| 345 |
|
| 346 |
---
|
| 347 |
|
| 348 |
+
## Getting Started
|
| 349 |
|
| 350 |
+
### Hugging Face Model Hub
|
| 351 |
+
```bash
|
| 352 |
+
# Clone the model repository
|
| 353 |
+
git lfs install
|
| 354 |
+
git clone https://huggingface.co/maya-research/maya-1-voice
|
| 355 |
|
| 356 |
+
# Or load directly in Python
|
| 357 |
+
from transformers import AutoModelForCausalLM
|
| 358 |
+
model = AutoModelForCausalLM.from_pretrained("maya-research/maya-1-voice")
|
| 359 |
```
|
|
|
|
| 360 |
|
| 361 |
+
### Requirements
|
| 362 |
+
```bash
|
| 363 |
+
pip install torch transformers snac soundfile
|
| 364 |
```
|
| 365 |
|
| 366 |
+
### Additional Resources
|
| 367 |
+
- **Full emotion list:** [emotions.txt](https://huggingface.co/maya-research/maya-1-voice/blob/main/emotions.txt)
|
| 368 |
+
- **Prompt examples:** [prompt.txt](https://huggingface.co/maya-research/maya-1-voice/blob/main/prompt.txt)
|
| 369 |
+
- **Streaming script:** [vllm_streaming_inference.py](https://huggingface.co/maya-research/maya-1-voice/blob/main/vllm_streaming_inference.py)
|
| 370 |
|
| 371 |
+
---
|
| 372 |
|
| 373 |
+
## Citations & References
|
| 374 |
|
| 375 |
+
If you use Maya-1-Voice in your research or product, please cite:
|
| 376 |
+
|
| 377 |
+
```bibtex
|
| 378 |
+
@misc{maya1voice2024,
|
| 379 |
+
title={Maya-1-Voice: Open Source Voice AI with Emotional Intelligence},
|
| 380 |
+
author={Maya Research},
|
| 381 |
+
year={2024},
|
| 382 |
+
publisher={Hugging Face},
|
| 383 |
+
howpublished={\url{https://huggingface.co/maya-research/maya-1-voice}},
|
| 384 |
+
}
|
| 385 |
+
```
|
| 386 |
|
| 387 |
+
**Key Technologies:**
|
| 388 |
+
- SNAC Neural Audio Codec: https://github.com/hubertsiuzdak/snac
|
| 389 |
+
- Mimi Adversarial Codec: https://huggingface.co/kyutai/mimi
|
| 390 |
+
- vLLM Inference Engine: https://docs.vllm.ai/
|
| 391 |
|
| 392 |
+
---
|
| 393 |
|
| 394 |
+
## Why We Build Open Source Voice AI
|
| 395 |
|
| 396 |
+
Voice AI will be everywhere, but it's fundamentally broken for 90% of the world. Current voice models only work well for a narrow slice of English speakers because training data for most accents, languages, and speaking styles simply doesn't exist.
|
| 397 |
|
| 398 |
+
**Maya Research** builds emotionally intelligent, native voice models that finally let the rest of the world speak. We're open source because we believe voice intelligence should not be a privilege reserved for the few.
|
| 399 |
|
| 400 |
+
**Technology should be open** - The best voice AI tools should not be locked behind proprietary APIs charging per-second fees.
|
| 401 |
|
| 402 |
+
**Community drives innovation** - Open source accelerates research. When developers worldwide can build on our work, everyone wins.
|
| 403 |
+
|
| 404 |
+
**Voice intelligence for everyone** - We're building for the 90% of the world ignored by mainstream voice AI. That requires open models, not closed platforms.
|
| 405 |
|
| 406 |
---
|
| 407 |
|
| 408 |
+
**Maya Research** - Building voice intelligence for the 90% of the world left behind by mainstream AI.
|
| 409 |
+
|
| 410 |
+
**Website:** [mayaresearch.ai](https://mayaresearch.ai)
|
| 411 |
+
**Twitter/X:** [@mayaresearch_ai](https://x.com/mayaresearch_ai)
|
| 412 |
+
**Hugging Face:** [maya-research](https://huggingface.co/maya-research)
|
| 413 |
+
**Backed by:** South Park Commons
|
| 414 |
+
|
| 415 |
+
**License:** Apache 2.0
|
| 416 |
+
**Mission:** Emotionally intelligent voice models that finally let everyone speak
|