HiMind commited on
Commit
07bf638
·
verified ·
1 Parent(s): e2a5429

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +317 -4
README.md CHANGED
@@ -48,9 +48,12 @@ This is not a training checkpoint meant to be unpacked and rebuilt from ingredie
48
  - Voice selection by name
49
  - Emotion selection by name
50
  - Fuzzy matching for names
 
51
  - Optional reference-audio overrides
52
  - Packed voices and emotions inside one artifact
53
  - CLI usage for quick testing
 
 
54
 
55
  ## Requirements
56
 
@@ -80,7 +83,7 @@ If you are using the Hugging Face repo, download the bundle and place it next to
80
  python PackedTTS.py --bundle tts.pt --list
81
  ```
82
 
83
- ### 4) Generate speech
84
 
85
  ```bash
86
  python PackedTTS.py \
@@ -91,21 +94,168 @@ python PackedTTS.py \
91
  --output output.wav
92
  ```
93
 
94
- ## Reference-audio overrides
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
- You can override the packed voice or emotion at runtime using reference audio:
97
 
98
  ```bash
99
  python PackedTTS.py \
100
  --bundle tts.pt \
101
- --text "Hi, this is a custom test." \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  --voice-ref path/to/voice_reference.wav \
 
 
 
 
 
 
 
 
 
 
 
103
  --emo-ref path/to/emotion_reference.wav \
104
  --output output.wav
105
  ```
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  ## Python usage
108
 
 
 
109
  ```python
110
  from pathlib import Path
111
  import soundfile as sf
@@ -128,6 +278,158 @@ sf.write("output.wav", audio, sr)
128
  print(meta)
129
  ```
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  ## How it works
132
 
133
  PackedTTS restores the full runtime bundle and then runs synthesis in three stages:
@@ -137,6 +439,7 @@ PackedTTS restores the full runtime bundle and then runs synthesis in three stag
137
  * The bundle stores named voices and emotions.
138
  * A voice can be selected by name or replaced with reference audio.
139
  * An emotion can be selected by name or replaced with reference audio.
 
140
 
141
  2. **Build conditionals**
142
 
@@ -152,6 +455,8 @@ PackedTTS restores the full runtime bundle and then runs synthesis in three stag
152
 
153
  The result is a single packed synthesis workflow that does not require rebuilding the voice/emotion registry at runtime.
154
 
 
 
155
  ## Expected file behavior
156
 
157
  The script expects the bundle to contain:
@@ -167,6 +472,8 @@ The script expects the bundle to contain:
167
 
168
  If a voice or emotion is not found by exact name, PackedTTS will try normalized matching and then fuzzy matching.
169
 
 
 
170
  ## Example command-line options
171
 
172
  * `--bundle` — path to `tts.pt`
@@ -182,6 +489,8 @@ If a voice or emotion is not found by exact name, PackedTTS will try normalized
182
  * `--output` — output WAV path
183
  * `--list` — print packed voices and emotions
184
 
 
 
185
  ## Notes
186
 
187
  * This repo is meant for inference and testing.
@@ -189,6 +498,8 @@ If a voice or emotion is not found by exact name, PackedTTS will try normalized
189
  * If the underlying model architecture, tokenizer, or conditioning schema changes, rebuild `tts.pt`.
190
  * Voice and emotion names depend on the bundle version.
191
 
 
 
192
  ## Hugging Face usage
193
 
194
  This repo is designed to work well as a Hugging Face model repository and as a Hugging Face Space backend:
@@ -198,6 +509,8 @@ This repo is designed to work well as a Hugging Face model repository and as a H
198
  * the runtime can load `PackedTTS.py`
199
  * users can generate speech without rebuilding the bundle
200
 
 
 
201
  ## Credits
202
 
203
  Built on top of:
 
48
  - Voice selection by name
49
  - Emotion selection by name
50
  - Fuzzy matching for names
51
+ - Default voice and emotion fallback
52
  - Optional reference-audio overrides
53
  - Packed voices and emotions inside one artifact
54
  - CLI usage for quick testing
55
+ - Python API usage
56
+ - Hugging Face Space friendly
57
 
58
  ## Requirements
59
 
 
83
  python PackedTTS.py --bundle tts.pt --list
84
  ```
85
 
86
+ ### 4) Generate speech with an explicit voice and emotion
87
 
88
  ```bash
89
  python PackedTTS.py \
 
94
  --output output.wav
95
  ```
96
 
97
+ ---
98
+
99
+ ## Command-line examples
100
+
101
+ ### List mode
102
+
103
+ Print all packed voices and emotions without generating audio:
104
+
105
+ ```bash
106
+ python PackedTTS.py --bundle tts.pt --list
107
+ ```
108
+
109
+ ### Basic generation
110
+
111
+ Generate speech with explicit voice and emotion:
112
+
113
+ ```bash
114
+ python PackedTTS.py \
115
+ --bundle tts.pt \
116
+ --text "This is a normal synthesis test." \
117
+ --voice "Sarah" \
118
+ --emotion "Disgust" \
119
+ --output output.wav
120
+ ```
121
+
122
+ ### Voice only
123
+
124
+ Let the bundle choose the emotion from the packed voice defaults or fallback rules:
125
+
126
+ ```bash
127
+ python PackedTTS.py \
128
+ --bundle tts.pt \
129
+ --text "This is voice-only generation." \
130
+ --voice "Sarah" \
131
+ --output output.wav
132
+ ```
133
+
134
+ ### Emotion only
135
+
136
+ Let the bundle choose a default or fallback voice while forcing an emotion:
137
+
138
+ ```bash
139
+ python PackedTTS.py \
140
+ --bundle tts.pt \
141
+ --text "This is emotion-only generation." \
142
+ --emotion "Happy" \
143
+ --output output.wav
144
+ ```
145
+
146
+ ### No voice and no emotion
147
 
148
+ Use the bundle defaults or random fallback selection:
149
 
150
  ```bash
151
  python PackedTTS.py \
152
  --bundle tts.pt \
153
+ --text "This uses the bundle defaults." \
154
+ --output output.wav
155
+ ```
156
+
157
+ ### Custom sampling parameters
158
+
159
+ Adjust guidance, temperature, and style strength:
160
+
161
+ ```bash
162
+ python PackedTTS.py \
163
+ --bundle tts.pt \
164
+ --text "More expressive speech with custom sampling." \
165
+ --voice "Sarah" \
166
+ --emotion "Angry" \
167
+ --cfg-weight 0.7 \
168
+ --temperature 0.9 \
169
+ --exaggeration 0.6 \
170
+ --seed 123 \
171
+ --output output.wav
172
+ ```
173
+
174
+ ### Different output path
175
+
176
+ Write the result anywhere you want:
177
+
178
+ ```bash
179
+ python PackedTTS.py \
180
+ --bundle tts.pt \
181
+ --text "Saving to a custom file." \
182
+ --voice "Sarah" \
183
+ --emotion "Calm" \
184
+ --output results/custom_output.wav
185
+ ```
186
+
187
+ ### Fuzzy matching for names
188
+
189
+ If the voice or emotion name is close but not exact, PackedTTS will try normalized matching and then fuzzy matching.
190
+
191
+ Example:
192
+
193
+ ```bash
194
+ python PackedTTS.py \
195
+ --bundle tts.pt \
196
+ --text "This uses fuzzy matching." \
197
+ --voice "sara" \
198
+ --emotion "angr" \
199
+ --output output.wav
200
+ ```
201
+
202
+ ### Reference voice override
203
+
204
+ Use a reference voice file instead of a packed voice:
205
+
206
+ ```bash
207
+ python PackedTTS.py \
208
+ --bundle tts.pt \
209
+ --text "This voice comes from reference audio." \
210
  --voice-ref path/to/voice_reference.wav \
211
+ --output output.wav
212
+ ```
213
+
214
+ ### Reference emotion override
215
+
216
+ Use a reference emotion file instead of a packed emotion:
217
+
218
+ ```bash
219
+ python PackedTTS.py \
220
+ --bundle tts.pt \
221
+ --text "This emotion comes from reference audio." \
222
  --emo-ref path/to/emotion_reference.wav \
223
  --output output.wav
224
  ```
225
 
226
+ ### Both reference overrides
227
+
228
+ Override both the voice and emotion with reference audio:
229
+
230
+ ```bash
231
+ python PackedTTS.py \
232
+ --bundle tts.pt \
233
+ --text "Both voice and emotion are driven by reference audio." \
234
+ --voice-ref path/to/voice_reference.wav \
235
+ --emo-ref path/to/emotion_reference.wav \
236
+ --output output.wav
237
+ ```
238
+
239
+ ### Seeded generation
240
+
241
+ Use a fixed seed to make results more repeatable:
242
+
243
+ ```bash
244
+ python PackedTTS.py \
245
+ --bundle tts.pt \
246
+ --text "Seeded generation example." \
247
+ --voice "Sarah" \
248
+ --emotion "Disgust" \
249
+ --seed 42 \
250
+ --output output.wav
251
+ ```
252
+
253
+ ---
254
+
255
  ## Python usage
256
 
257
+ ### Basic API usage
258
+
259
  ```python
260
  from pathlib import Path
261
  import soundfile as sf
 
278
  print(meta)
279
  ```
280
 
281
+ ### Python usage with defaults
282
+
283
+ Let the model choose the default voice and emotion:
284
+
285
+ ```python
286
+ from pathlib import Path
287
+ import soundfile as sf
288
+
289
+ from PackedTTS import PackedTTS
290
+
291
+ tts = PackedTTS.load(Path("tts.pt"))
292
+
293
+ sr, audio, meta = tts.generate(
294
+ text="This uses the bundle defaults.",
295
+ seed=7,
296
+ )
297
+
298
+ sf.write("default_output.wav", audio, sr)
299
+ print(meta)
300
+ ```
301
+
302
+ ### Python usage with voice only
303
+
304
+ ```python
305
+ from pathlib import Path
306
+ import soundfile as sf
307
+
308
+ from PackedTTS import PackedTTS
309
+
310
+ tts = PackedTTS.load(Path("tts.pt"))
311
+
312
+ sr, audio, meta = tts.generate(
313
+ text="Voice selected, emotion resolved by the bundle.",
314
+ voice="Sarah",
315
+ seed=12,
316
+ )
317
+
318
+ sf.write("voice_only.wav", audio, sr)
319
+ print(meta)
320
+ ```
321
+
322
+ ### Python usage with emotion only
323
+
324
+ ```python
325
+ from pathlib import Path
326
+ import soundfile as sf
327
+
328
+ from PackedTTS import PackedTTS
329
+
330
+ tts = PackedTTS.load(Path("tts.pt"))
331
+
332
+ sr, audio, meta = tts.generate(
333
+ text="Emotion selected, voice resolved by the bundle.",
334
+ emotion="Happy",
335
+ seed=12,
336
+ )
337
+
338
+ sf.write("emotion_only.wav", audio, sr)
339
+ print(meta)
340
+ ```
341
+
342
+ ### Python usage with reference voice override
343
+
344
+ ```python
345
+ from pathlib import Path
346
+ import soundfile as sf
347
+
348
+ from PackedTTS import PackedTTS
349
+
350
+ tts = PackedTTS.load(Path("tts.pt"))
351
+
352
+ sr, audio, meta = tts.generate(
353
+ text="This uses voice reference audio.",
354
+ voice_ref="path/to/voice_reference.wav",
355
+ emotion="Calm",
356
+ seed=42,
357
+ )
358
+
359
+ sf.write("voice_ref_output.wav", audio, sr)
360
+ print(meta)
361
+ ```
362
+
363
+ ### Python usage with reference emotion override
364
+
365
+ ```python
366
+ from pathlib import Path
367
+ import soundfile as sf
368
+
369
+ from PackedTTS import PackedTTS
370
+
371
+ tts = PackedTTS.load(Path("tts.pt"))
372
+
373
+ sr, audio, meta = tts.generate(
374
+ text="This uses emotion reference audio.",
375
+ voice="Sarah",
376
+ emo_ref="path/to/emotion_reference.wav",
377
+ seed=42,
378
+ )
379
+
380
+ sf.write("emo_ref_output.wav", audio, sr)
381
+ print(meta)
382
+ ```
383
+
384
+ ### Python usage with both reference overrides
385
+
386
+ ```python
387
+ from pathlib import Path
388
+ import soundfile as sf
389
+
390
+ from PackedTTS import PackedTTS
391
+
392
+ tts = PackedTTS.load(Path("tts.pt"))
393
+
394
+ sr, audio, meta = tts.generate(
395
+ text="This uses both reference audio inputs.",
396
+ voice_ref="path/to/voice_reference.wav",
397
+ emo_ref="path/to/emotion_reference.wav",
398
+ seed=42,
399
+ )
400
+
401
+ sf.write("both_refs_output.wav", audio, sr)
402
+ print(meta)
403
+ ```
404
+
405
+ ### Python usage through the `forward` alias
406
+
407
+ `forward` is an alias for `generate`, so the model can be used like a callable runtime component:
408
+
409
+ ```python
410
+ from pathlib import Path
411
+ import soundfile as sf
412
+
413
+ from PackedTTS import PackedTTS
414
+
415
+ tts = PackedTTS.load(Path("tts.pt"))
416
+
417
+ sr, audio, meta = tts.forward(
418
+ text="This uses the forward alias.",
419
+ voice="Sarah",
420
+ emotion="Disgust",
421
+ cfg_weight=0.5,
422
+ temperature=0.8,
423
+ exaggeration=0.5,
424
+ seed=42,
425
+ )
426
+
427
+ sf.write("forward_output.wav", audio, sr)
428
+ print(meta)
429
+ ```
430
+
431
+ ---
432
+
433
  ## How it works
434
 
435
  PackedTTS restores the full runtime bundle and then runs synthesis in three stages:
 
439
  * The bundle stores named voices and emotions.
440
  * A voice can be selected by name or replaced with reference audio.
441
  * An emotion can be selected by name or replaced with reference audio.
442
+ * If exact matching fails, the runtime tries normalized matching and then fuzzy matching.
443
 
444
  2. **Build conditionals**
445
 
 
455
 
456
  The result is a single packed synthesis workflow that does not require rebuilding the voice/emotion registry at runtime.
457
 
458
+ ---
459
+
460
  ## Expected file behavior
461
 
462
  The script expects the bundle to contain:
 
472
 
473
  If a voice or emotion is not found by exact name, PackedTTS will try normalized matching and then fuzzy matching.
474
 
475
+ ---
476
+
477
  ## Example command-line options
478
 
479
  * `--bundle` — path to `tts.pt`
 
489
  * `--output` — output WAV path
490
  * `--list` — print packed voices and emotions
491
 
492
+ ---
493
+
494
  ## Notes
495
 
496
  * This repo is meant for inference and testing.
 
498
  * If the underlying model architecture, tokenizer, or conditioning schema changes, rebuild `tts.pt`.
499
  * Voice and emotion names depend on the bundle version.
500
 
501
+ ---
502
+
503
  ## Hugging Face usage
504
 
505
  This repo is designed to work well as a Hugging Face model repository and as a Hugging Face Space backend:
 
509
  * the runtime can load `PackedTTS.py`
510
  * users can generate speech without rebuilding the bundle
511
 
512
+ ---
513
+
514
  ## Credits
515
 
516
  Built on top of: