Spaces:
Running
Running
Yurii Paniv
commited on
Commit
•
9d153e7
1
Parent(s):
a2fc107
Black fixes
Browse files- app.py +5 -7
- ukrainian_tts/tts.py +3 -2
app.py
CHANGED
@@ -84,7 +84,9 @@ def tts(text: str, voice: str, stress: str, speed: float):
|
|
84 |
) # mitigate crashes on hf space
|
85 |
|
86 |
if getenv("HF_API_TOKEN") is not None:
|
87 |
-
log_queue.put(
|
|
|
|
|
88 |
|
89 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
90 |
_, text = ukr_tts.tts(text, speaker_name, stress_selected, fp, speed)
|
@@ -114,12 +116,8 @@ iface = gr.Interface(
|
|
114 |
value=StressOption.AutomaticStress.value,
|
115 |
),
|
116 |
gr.components.Slider(
|
117 |
-
label="Швидкість",
|
118 |
-
|
119 |
-
maximum=2,
|
120 |
-
value=1,
|
121 |
-
step=0.1
|
122 |
-
)
|
123 |
],
|
124 |
outputs=[
|
125 |
gr.components.Audio(label="Output"),
|
|
|
84 |
) # mitigate crashes on hf space
|
85 |
|
86 |
if getenv("HF_API_TOKEN") is not None:
|
87 |
+
log_queue.put(
|
88 |
+
[text, speaker_name, stress_selected, speed, str(datetime.utcnow())]
|
89 |
+
)
|
90 |
|
91 |
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
92 |
_, text = ukr_tts.tts(text, speaker_name, stress_selected, fp, speed)
|
|
|
116 |
value=StressOption.AutomaticStress.value,
|
117 |
),
|
118 |
gr.components.Slider(
|
119 |
+
label="Швидкість", minimum=0.5, maximum=2, value=1, step=0.1
|
120 |
+
),
|
|
|
|
|
|
|
|
|
121 |
],
|
122 |
outputs=[
|
123 |
gr.components.Audio(label="Output"),
|
ukrainian_tts/tts.py
CHANGED
@@ -67,11 +67,12 @@ class TTS:
|
|
67 |
text = preprocess_text(text, stress)
|
68 |
text = sentence_to_stress(text, stress_with_model if stress else stress_dict)
|
69 |
|
70 |
-
|
71 |
# synthesis
|
72 |
with no_grad():
|
73 |
start = time.time()
|
74 |
-
wav = self.synthesizer(
|
|
|
|
|
75 |
|
76 |
rtf = (time.time() - start) / (len(wav) / self.synthesizer.fs)
|
77 |
print(f"RTF = {rtf:5f}")
|
|
|
67 |
text = preprocess_text(text, stress)
|
68 |
text = sentence_to_stress(text, stress_with_model if stress else stress_dict)
|
69 |
|
|
|
70 |
# synthesis
|
71 |
with no_grad():
|
72 |
start = time.time()
|
73 |
+
wav = self.synthesizer(
|
74 |
+
text, sids=np.array(voice), decode_conf={"alpha": 1 / speed}
|
75 |
+
)["wav"]
|
76 |
|
77 |
rtf = (time.time() - start) / (len(wav) / self.synthesizer.fs)
|
78 |
print(f"RTF = {rtf:5f}")
|