Добавлены ударения (RUAccent) + нормализация
Browse files- eremin_tts.py +17 -1
eremin_tts.py
CHANGED
|
@@ -31,6 +31,7 @@ import numpy as np
|
|
| 31 |
import soundfile as sf
|
| 32 |
import torch
|
| 33 |
import torchaudio
|
|
|
|
| 34 |
|
| 35 |
from f5_tts.infer.utils_infer import (
|
| 36 |
infer_process,
|
|
@@ -142,11 +143,26 @@ def main():
|
|
| 142 |
model, vocoder = load_f5_model()
|
| 143 |
ref_audio_p, ref_text_p = prepare_ref()
|
| 144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
raw_sents = [s.strip() for s in SENT_SPLIT_RE.split(args.text)
|
| 146 |
if s and s.strip()]
|
| 147 |
if not raw_sents:
|
| 148 |
raw_sents = [args.text]
|
| 149 |
-
sentences = [normalize_numbers(s) for s in raw_sents]
|
| 150 |
|
| 151 |
print(f"Предложений: {len(sentences)}")
|
| 152 |
for i, s in enumerate(sentences, 1):
|
|
|
|
| 31 |
import soundfile as sf
|
| 32 |
import torch
|
| 33 |
import torchaudio
|
| 34 |
+
from ruaccent import RUAccent
|
| 35 |
|
| 36 |
from f5_tts.infer.utils_infer import (
|
| 37 |
infer_process,
|
|
|
|
| 143 |
model, vocoder = load_f5_model()
|
| 144 |
ref_audio_p, ref_text_p = prepare_ref()
|
| 145 |
|
| 146 |
+
# RUAccent: расстановка ударений
|
| 147 |
+
print("Loading RUAccent...")
|
| 148 |
+
accentizer = RUAccent()
|
| 149 |
+
accentizer.load(omograph_model_size='turbo3.1', use_dictionary=True,
|
| 150 |
+
tiny_mode=False)
|
| 151 |
+
print(" RUAccent loaded.")
|
| 152 |
+
|
| 153 |
+
def _accent(text):
|
| 154 |
+
if not text.strip() or '+' in text:
|
| 155 |
+
return text
|
| 156 |
+
try:
|
| 157 |
+
return accentizer.process_all(text)
|
| 158 |
+
except Exception:
|
| 159 |
+
return text
|
| 160 |
+
|
| 161 |
raw_sents = [s.strip() for s in SENT_SPLIT_RE.split(args.text)
|
| 162 |
if s and s.strip()]
|
| 163 |
if not raw_sents:
|
| 164 |
raw_sents = [args.text]
|
| 165 |
+
sentences = [_accent(normalize_numbers(s)) for s in raw_sents]
|
| 166 |
|
| 167 |
print(f"Предложений: {len(sentences)}")
|
| 168 |
for i, s in enumerate(sentences, 1):
|