Upload app.py
Browse files
app.py
CHANGED
@@ -14,11 +14,14 @@ en_text = "The North Wind and the Sun were disputing which was the stronger, whe
|
|
14 |
pt_text = "O vento norte e o Sol discutiam quem era o mais forte, quando surgiu um viajante envolvido numa capa."
|
15 |
|
16 |
TTS_VOICES = [
|
|
|
17 |
"Judith",
|
18 |
-
"Luc",
|
19 |
"Kerstin",
|
20 |
-
"Ed",
|
21 |
"Linda"
|
|
|
|
|
|
|
|
|
22 |
]
|
23 |
|
24 |
TTS_LANGUAGES = [
|
@@ -31,11 +34,11 @@ TTS_LANGUAGES = [
|
|
31 |
|
32 |
|
33 |
my_examples = [
|
34 |
-
[lb_text, "
|
35 |
-
[de_text, "
|
36 |
-
[fr_text, "
|
37 |
-
[en_text, "
|
38 |
-
[pt_text, "
|
39 |
]
|
40 |
|
41 |
my_article = "<h3>User guide</h3><p>1. Press the Submit button to generate a speech file with the default values. 2. Change the default values by clicking an example row. 3. Select a language and a voice and enter your own text. Have fun!</p><p>Go to <a href='https://www.web3.lu/category/audio-technologies/'>Internet with a Brain</a> to read some technical infos.</p>"
|
@@ -50,18 +53,11 @@ my_outputs = gr.outputs.Audio(type="file", label="Output Audio")
|
|
50 |
|
51 |
def tts(text: str, speaker_idx: str, language_idx: str):
|
52 |
best_model_path = hf_hub_download(repo_id=REPO_ID, filename="best_model.pth")
|
53 |
-
print(best_model_path)
|
54 |
config_path = hf_hub_download(repo_id=REPO_ID, filename="config.json")
|
55 |
-
print(config_path)
|
56 |
speakers_path = hf_hub_download(repo_id=REPO_ID, filename="speakers.pth")
|
57 |
-
print(speakers_path)
|
58 |
languages_path = hf_hub_download(repo_id=REPO_ID, filename="language_ids.json")
|
59 |
-
# languages_path = "/home/mbarnig/GRADIO/gradio/language_ids.json"
|
60 |
-
print(languages_path)
|
61 |
speaker_encoder_model_path = hf_hub_download(repo_id=REPO_ID, filename="model_se.pth")
|
62 |
-
print(speaker_encoder_model_path)
|
63 |
speaker_encoder_config_path = hf_hub_download(repo_id=REPO_ID, filename="config_se.json")
|
64 |
-
print(speaker_encoder_config_path)
|
65 |
|
66 |
# init synthesizer
|
67 |
synthesizer = Synthesizer(
|
@@ -77,10 +73,7 @@ def tts(text: str, speaker_idx: str, language_idx: str):
|
|
77 |
)
|
78 |
|
79 |
# create audio file
|
80 |
-
print("speaker_idx : " + speaker_idx)
|
81 |
-
print("language_idx : " + language_idx)
|
82 |
wavs = synthesizer.tts(text, speaker_idx, language_idx)
|
83 |
-
# wavs = synthesizer.tts(text, "Ed", "x-lb")
|
84 |
with tempfile.NamedTemporaryFile(suffix = ".wav", delete = False) as fp:
|
85 |
synthesizer.save_wav(wavs, fp)
|
86 |
return fp.name
|
|
|
14 |
pt_text = "O vento norte e o Sol discutiam quem era o mais forte, quando surgiu um viajante envolvido numa capa."
|
15 |
|
16 |
TTS_VOICES = [
|
17 |
+
"Bunny",
|
18 |
"Judith",
|
|
|
19 |
"Kerstin",
|
|
|
20 |
"Linda"
|
21 |
+
"Bernard",
|
22 |
+
"Ed",
|
23 |
+
"Guy",
|
24 |
+
"Thorsten"
|
25 |
]
|
26 |
|
27 |
TTS_LANGUAGES = [
|
|
|
34 |
|
35 |
|
36 |
my_examples = [
|
37 |
+
[lb_text, "Judith", "Lëtzebuergesch"],
|
38 |
+
[de_text, "Thorsten", "Deutsch"],
|
39 |
+
[fr_text, "Bernard", "Français"],
|
40 |
+
[en_text, "Linda", "English"],
|
41 |
+
[pt_text, "Ed", "Português"]
|
42 |
]
|
43 |
|
44 |
my_article = "<h3>User guide</h3><p>1. Press the Submit button to generate a speech file with the default values. 2. Change the default values by clicking an example row. 3. Select a language and a voice and enter your own text. Have fun!</p><p>Go to <a href='https://www.web3.lu/category/audio-technologies/'>Internet with a Brain</a> to read some technical infos.</p>"
|
|
|
53 |
|
54 |
def tts(text: str, speaker_idx: str, language_idx: str):
|
55 |
best_model_path = hf_hub_download(repo_id=REPO_ID, filename="best_model.pth")
|
|
|
56 |
config_path = hf_hub_download(repo_id=REPO_ID, filename="config.json")
|
|
|
57 |
speakers_path = hf_hub_download(repo_id=REPO_ID, filename="speakers.pth")
|
|
|
58 |
languages_path = hf_hub_download(repo_id=REPO_ID, filename="language_ids.json")
|
|
|
|
|
59 |
speaker_encoder_model_path = hf_hub_download(repo_id=REPO_ID, filename="model_se.pth")
|
|
|
60 |
speaker_encoder_config_path = hf_hub_download(repo_id=REPO_ID, filename="config_se.json")
|
|
|
61 |
|
62 |
# init synthesizer
|
63 |
synthesizer = Synthesizer(
|
|
|
73 |
)
|
74 |
|
75 |
# create audio file
|
|
|
|
|
76 |
wavs = synthesizer.tts(text, speaker_idx, language_idx)
|
|
|
77 |
with tempfile.NamedTemporaryFile(suffix = ".wav", delete = False) as fp:
|
78 |
synthesizer.save_wav(wavs, fp)
|
79 |
return fp.name
|