Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,10 +14,14 @@ fr_text = "La bise et le soleil se disputaient, chacun assurant qu'il était le
|
|
14 |
en_text = "The North Wind and the Sun were disputing which was the stronger, when a traveler came along wrapped in a warm cloak."
|
15 |
pt_text = "O vento norte e o Sol discutiam quem era o mais forte, quando surgiu um viajante envolvido numa capa."
|
16 |
|
17 |
-
|
|
|
|
|
18 |
]
|
19 |
|
20 |
-
|
|
|
|
|
21 |
]
|
22 |
|
23 |
my_examples = [
|
@@ -28,24 +32,35 @@ my_article = "<h3>User guide</h3>"
|
|
28 |
|
29 |
my_inputs = [
|
30 |
gr.Textbox(lines=5, label="Input Text"),
|
31 |
-
|
32 |
-
|
33 |
]
|
34 |
|
35 |
my_outputs = gr.Audio(type="filepath", label="Output Audio")
|
36 |
|
37 |
def tts(text: str, speaker_idx: str, language_idx: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
best_model_path = hf_hub_download(repo_id=REPO_ID, filename="checkpoint_180000.pth")
|
39 |
config_path = hf_hub_download(repo_id=REPO_ID, filename="config.json")
|
40 |
-
speakers_path = hf_hub_download(repo_id=REPO_ID, filename="speakers.pth")
|
41 |
-
languages_path = hf_hub_download(repo_id=REPO_ID, filename="language_ids.json")
|
42 |
|
43 |
# init synthesizer
|
44 |
synthesizer = Synthesizer(
|
45 |
best_model_path,
|
46 |
config_path,
|
47 |
-
speakers_path,
|
48 |
-
languages_path,
|
|
|
|
|
49 |
None,
|
50 |
None,
|
51 |
False
|
@@ -53,7 +68,7 @@ def tts(text: str, speaker_idx: str, language_idx: str):
|
|
53 |
|
54 |
# create audio file
|
55 |
# wavs = synthesizer.tts(text, speaker_idx, language_idx
|
56 |
-
wavs = synthesizer.tts(
|
57 |
with tempfile.NamedTemporaryFile(suffix = ".wav", delete = False) as fp:
|
58 |
synthesizer.save_wav(wavs, fp)
|
59 |
return fp.name
|
@@ -68,4 +83,4 @@ iface = gr.Interface(
|
|
68 |
examples = my_examples,
|
69 |
allow_flagging="never"
|
70 |
)
|
71 |
-
iface.launch()
|
|
|
14 |
en_text = "The North Wind and the Sun were disputing which was the stronger, when a traveler came along wrapped in a warm cloak."
|
15 |
pt_text = "O vento norte e o Sol discutiam quem era o mais forte, quando surgiu um viajante envolvido numa capa."
|
16 |
|
17 |
+
my_voices = [
|
18 |
+
"Male",
|
19 |
+
"Female"
|
20 |
]
|
21 |
|
22 |
+
my_languages = [
|
23 |
+
"Lëtzebuergesch",
|
24 |
+
"Deutsch"
|
25 |
]
|
26 |
|
27 |
my_examples = [
|
|
|
32 |
|
33 |
my_inputs = [
|
34 |
gr.Textbox(lines=5, label="Input Text"),
|
35 |
+
gr.Radio(label="Speaker", choices = my_voices, value = "Male"),
|
36 |
+
gr.Radio(label="Language", choices = my_languages, value = "Lëtzebuergesch"),
|
37 |
]
|
38 |
|
39 |
my_outputs = gr.Audio(type="filepath", label="Output Audio")
|
40 |
|
41 |
def tts(text: str, speaker_idx: str, language_idx: str):
|
42 |
+
if speaker_idx == "Male":
|
43 |
+
speaker_idx = "Max"
|
44 |
+
else:
|
45 |
+
speaker_idx = "Mod"
|
46 |
+
if language_idx == "Lëtzebuergesch":
|
47 |
+
language_idx = "D:\\MULTI-LOD\\mailabs\\x-lb"
|
48 |
+
else:
|
49 |
+
language_idx = "D:\\MULTI-LOD\\mailabs\\x-de"
|
50 |
+
|
51 |
best_model_path = hf_hub_download(repo_id=REPO_ID, filename="checkpoint_180000.pth")
|
52 |
config_path = hf_hub_download(repo_id=REPO_ID, filename="config.json")
|
53 |
+
# speakers_path = hf_hub_download(repo_id=REPO_ID, filename="speakers.pth")
|
54 |
+
# languages_path = hf_hub_download(repo_id=REPO_ID, filename="language_ids.json")
|
55 |
|
56 |
# init synthesizer
|
57 |
synthesizer = Synthesizer(
|
58 |
best_model_path,
|
59 |
config_path,
|
60 |
+
# speakers_path,
|
61 |
+
# languages_path,
|
62 |
+
None,
|
63 |
+
None,
|
64 |
None,
|
65 |
None,
|
66 |
False
|
|
|
68 |
|
69 |
# create audio file
|
70 |
# wavs = synthesizer.tts(text, speaker_idx, language_idx
|
71 |
+
wavs = synthesizer.tts(text, speaker_idx, language_idx)
|
72 |
with tempfile.NamedTemporaryFile(suffix = ".wav", delete = False) as fp:
|
73 |
synthesizer.save_wav(wavs, fp)
|
74 |
return fp.name
|
|
|
83 |
examples = my_examples,
|
84 |
allow_flagging="never"
|
85 |
)
|
86 |
+
iface.launch()
|