Spaces:
Running
Running
Yurii Paniv
commited on
Commit
•
f64a87d
1
Parent(s):
b663da0
Add queue, avoid memory leak
Browse files
app.py
CHANGED
@@ -39,18 +39,18 @@ for MODEL_NAME in MODEL_NAMES:
|
|
39 |
download(model_link, model_path)
|
40 |
download(config_link, config_path)
|
41 |
|
|
|
|
|
|
|
|
|
|
|
42 |
synthesizer = Synthesizer(
|
43 |
model_path, config_path, None, None, None,
|
44 |
)
|
45 |
-
MODELS[MODEL_NAME] = synthesizer
|
46 |
-
|
47 |
-
|
48 |
-
def tts(text: str, model_name: str):
|
49 |
text = preprocess_text(text)
|
50 |
text_limit = 300
|
51 |
text = text if len(text) < text_limit else text[0:text_limit] # mitigate crashes on hf space
|
52 |
print(text, datetime.utcnow())
|
53 |
-
synthesizer = MODELS.get(model_name, None)
|
54 |
if synthesizer is None:
|
55 |
raise NameError("model not found")
|
56 |
wavs = synthesizer.tts(text)
|
@@ -68,17 +68,16 @@ iface = gr.Interface(
|
|
68 |
label="Input",
|
69 |
default="Введ+іть, б+удь л+аска, сво+є р+ечення.",
|
70 |
),
|
71 |
-
gr.inputs.Radio(
|
72 |
-
|
73 |
-
|
74 |
-
),
|
75 |
],
|
76 |
outputs=gr.outputs.Audio(label="Output"),
|
77 |
-
enable_queue=True,
|
78 |
title="🐸💬🇺🇦 - Coqui TTS",
|
79 |
theme="huggingface",
|
80 |
description="Україномовний🇺🇦 TTS за допомогою Coqui TTS (для наголосу використовуйте + перед голосною)",
|
81 |
article="Якщо вам подобається, підтримайте за посиланням: [SUPPORT LINK](https://send.monobank.ua/jar/48iHq4xAXm), " +
|
82 |
"Github: [https://github.com/robinhad/ukrainian-tts](https://github.com/robinhad/ukrainian-tts)",
|
83 |
)
|
84 |
-
iface.launch()
|
|
|
39 |
download(model_link, model_path)
|
40 |
download(config_link, config_path)
|
41 |
|
42 |
+
|
43 |
+
#MODELS[MODEL_NAME] = synthesizer
|
44 |
+
|
45 |
+
|
46 |
+
def tts(text: str):
|
47 |
synthesizer = Synthesizer(
|
48 |
model_path, config_path, None, None, None,
|
49 |
)
|
|
|
|
|
|
|
|
|
50 |
text = preprocess_text(text)
|
51 |
text_limit = 300
|
52 |
text = text if len(text) < text_limit else text[0:text_limit] # mitigate crashes on hf space
|
53 |
print(text, datetime.utcnow())
|
|
|
54 |
if synthesizer is None:
|
55 |
raise NameError("model not found")
|
56 |
wavs = synthesizer.tts(text)
|
|
|
68 |
label="Input",
|
69 |
default="Введ+іть, б+удь л+аска, сво+є р+ечення.",
|
70 |
),
|
71 |
+
#gr.inputs.Radio(
|
72 |
+
# label="Виберіть TTS модель",
|
73 |
+
# choices=MODEL_NAMES,
|
74 |
+
#),
|
75 |
],
|
76 |
outputs=gr.outputs.Audio(label="Output"),
|
|
|
77 |
title="🐸💬🇺🇦 - Coqui TTS",
|
78 |
theme="huggingface",
|
79 |
description="Україномовний🇺🇦 TTS за допомогою Coqui TTS (для наголосу використовуйте + перед голосною)",
|
80 |
article="Якщо вам подобається, підтримайте за посиланням: [SUPPORT LINK](https://send.monobank.ua/jar/48iHq4xAXm), " +
|
81 |
"Github: [https://github.com/robinhad/ukrainian-tts](https://github.com/robinhad/ukrainian-tts)",
|
82 |
)
|
83 |
+
iface.launch(enable_queue=True)
|