Add TeraTTSv2 Gradio demo
Browse files
README.md
CHANGED
|
@@ -22,6 +22,9 @@ For installation, Python examples, ONNX options, and model downloads, visit
|
|
| 22 |
The demo also displays the normalized text sent to the model after number
|
| 23 |
expansion, automatic Russian stress marking, and Unicode normalization.
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
> **Important:** `<ru>…</ru>` text receives automatic stress markers by
|
| 26 |
> default. For an English voice speaking Russian, try a `duration_scale` below
|
| 27 |
> `1`—`0.8` is a useful starting point.
|
|
|
|
| 22 |
The demo also displays the normalized text sent to the model after number
|
| 23 |
expansion, automatic Russian stress marking, and Unicode normalization.
|
| 24 |
|
| 25 |
+
`ru_f1` and `ru_m5` are the recommended Russian speaker prompts and appear
|
| 26 |
+
first in the Space selector. Language tags are required for synthesis.
|
| 27 |
+
|
| 28 |
> **Important:** `<ru>…</ru>` text receives automatic stress markers by
|
| 29 |
> default. For an English voice speaking Russian, try a `duration_scale` below
|
| 30 |
> `1`—`0.8` is a useful starting point.
|
app.py
CHANGED
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
| 4 |
|
| 5 |
import os
|
| 6 |
import logging
|
|
|
|
| 7 |
from functools import lru_cache
|
| 8 |
|
| 9 |
import numpy as np
|
|
@@ -51,7 +52,11 @@ def synthesize(
|
|
| 51 |
except Exception as error:
|
| 52 |
LOGGER.exception("TeraTTS synthesis failed")
|
| 53 |
raise gr.Error(f"Synthesis failed: {error}") from error
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
demo = gr.Interface(
|
|
@@ -70,10 +75,10 @@ demo = gr.Interface(
|
|
| 70 |
),
|
| 71 |
gr.Dropdown(
|
| 72 |
[
|
| 73 |
-
("Russian female 1", "ru_f1"),
|
|
|
|
| 74 |
("Russian female 2", "ru_f2"),
|
| 75 |
("Russian male 1", "ru_m1"),
|
| 76 |
-
("Russian male 5", "ru_m5"),
|
| 77 |
("English female 3", "eng_f3"),
|
| 78 |
("English female 4 — whisper", "eng_f4_whisper"),
|
| 79 |
("English female 5", "eng_f5"),
|
|
@@ -109,7 +114,7 @@ demo = gr.Interface(
|
|
| 109 |
],
|
| 110 |
outputs=[
|
| 111 |
gr.Audio(label="TeraTTSv2", type="numpy"),
|
| 112 |
-
gr.Textbox(label="Normalized text
|
| 113 |
],
|
| 114 |
title="TeraTTSv2",
|
| 115 |
description="""
|
|
@@ -117,14 +122,18 @@ demo = gr.Interface(
|
|
| 117 |
|
| 118 |
- **Use TeraTTS locally:** visit [TeraSpace/TeraTTSv2](https://huggingface.co/TeraSpace/TeraTTSv2)
|
| 119 |
for installation, Python examples, ONNX options, and downloadable model files.
|
|
|
|
|
|
|
| 120 |
- **Russian stress is automatic:** text inside `<ru>…</ru>` receives stress
|
| 121 |
markers by default; any manual `+` marker is preserved.
|
| 122 |
- **English voice speaking Russian:** lower **Duration scale** below `1`
|
| 123 |
(start around `0.8`) and adjust by ear.
|
| 124 |
|
| 125 |
-
|
| 126 |
-
higher-fidelity sampler. Dictionary-only stress saves
|
| 127 |
-
RUAccent neural models. Numbers are spelled out from their
|
|
|
|
|
|
|
| 128 |
""",
|
| 129 |
)
|
| 130 |
|
|
|
|
| 4 |
|
| 5 |
import os
|
| 6 |
import logging
|
| 7 |
+
import unicodedata
|
| 8 |
from functools import lru_cache
|
| 9 |
|
| 10 |
import numpy as np
|
|
|
|
| 52 |
except Exception as error:
|
| 53 |
LOGGER.exception("TeraTTS synthesis failed")
|
| 54 |
raise gr.Error(f"Synthesis failed: {error}") from error
|
| 55 |
+
# ONNX receives NFKD because that is how its vocabulary was trained. Show
|
| 56 |
+
# users the identical text in normal composed Unicode so ``й``/``ё`` stay
|
| 57 |
+
# legible in the browser instead of appearing as a letter plus a detached
|
| 58 |
+
# combining mark.
|
| 59 |
+
return (44_100, waveform), unicodedata.normalize("NFC", normalized_text)
|
| 60 |
|
| 61 |
|
| 62 |
demo = gr.Interface(
|
|
|
|
| 75 |
),
|
| 76 |
gr.Dropdown(
|
| 77 |
[
|
| 78 |
+
("★ Best: Russian female 1", "ru_f1"),
|
| 79 |
+
("★ Best: Russian male 5", "ru_m5"),
|
| 80 |
("Russian female 2", "ru_f2"),
|
| 81 |
("Russian male 1", "ru_m1"),
|
|
|
|
| 82 |
("English female 3", "eng_f3"),
|
| 83 |
("English female 4 — whisper", "eng_f4_whisper"),
|
| 84 |
("English female 5", "eng_f5"),
|
|
|
|
| 114 |
],
|
| 115 |
outputs=[
|
| 116 |
gr.Audio(label="TeraTTSv2", type="numpy"),
|
| 117 |
+
gr.Textbox(label="Normalized text", lines=5, interactive=False),
|
| 118 |
],
|
| 119 |
title="TeraTTSv2",
|
| 120 |
description="""
|
|
|
|
| 122 |
|
| 123 |
- **Use TeraTTS locally:** visit [TeraSpace/TeraTTSv2](https://huggingface.co/TeraSpace/TeraTTSv2)
|
| 124 |
for installation, Python examples, ONNX options, and downloadable model files.
|
| 125 |
+
- **Recommended speakers:** **Russian female 1** and **Russian male 5** are
|
| 126 |
+
the preferred voice prompts and appear first in the selector.
|
| 127 |
- **Russian stress is automatic:** text inside `<ru>…</ru>` receives stress
|
| 128 |
markers by default; any manual `+` marker is preserved.
|
| 129 |
- **English voice speaking Russian:** lower **Duration scale** below `1`
|
| 130 |
(start around `0.8`) and adjust by ear.
|
| 131 |
|
| 132 |
+
Language tags are required: use `<en>…</en>` or `<ru>…</ru>`. Distilled is
|
| 133 |
+
faster; Teacher uses the higher-fidelity sampler. Dictionary-only stress saves
|
| 134 |
+
memory by skipping RUAccent neural models. Numbers are spelled out from their
|
| 135 |
+
language tags. Unsupported characters are skipped and reported in the Space
|
| 136 |
+
logs.
|
| 137 |
""",
|
| 138 |
)
|
| 139 |
|