Upload app.py
Browse files
app.py
CHANGED
@@ -22,28 +22,28 @@ TTS_VOICES = [
|
|
22 |
]
|
23 |
|
24 |
TTS_LANGUAGES = [
|
25 |
-
"
|
26 |
-
"
|
27 |
-
"
|
28 |
-
"
|
29 |
-
"
|
30 |
]
|
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>"
|
42 |
|
43 |
my_inputs = [
|
44 |
gr.inputs.Textbox(lines=5, label="Input Text", default=lb_text),
|
45 |
-
gr.inputs.Radio(label="
|
46 |
-
gr.inputs.Radio(label="
|
47 |
]
|
48 |
|
49 |
my_outputs = gr.outputs.Audio(type="file", label="Output Audio")
|
@@ -56,6 +56,7 @@ def tts(text: str, speaker_idx: str, language_idx: str):
|
|
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 |
print(languages_path)
|
60 |
speaker_encoder_model_path = hf_hub_download(repo_id=REPO_ID, filename="model_se.pth")
|
61 |
print(speaker_encoder_model_path)
|
@@ -76,7 +77,10 @@ def tts(text: str, speaker_idx: str, language_idx: str):
|
|
76 |
)
|
77 |
|
78 |
# create audio file
|
|
|
|
|
79 |
wavs = synthesizer.tts(text, speaker_idx, language_idx)
|
|
|
80 |
with tempfile.NamedTemporaryFile(suffix = ".wav", delete = False) as fp:
|
81 |
synthesizer.save_wav(wavs, fp)
|
82 |
return fp.name
|
|
|
22 |
]
|
23 |
|
24 |
TTS_LANGUAGES = [
|
25 |
+
"English",
|
26 |
+
"Français",
|
27 |
+
"Português",
|
28 |
+
"Deutsch",
|
29 |
+
"Lëtzebuergesch"
|
30 |
]
|
31 |
|
32 |
|
33 |
my_examples = [
|
34 |
+
[lb_text, "Luc", "Lëtzebuergesch"],
|
35 |
+
[de_text, "Judith", "Deutsch"],
|
36 |
+
[fr_text, "Kerstin", "Français"],
|
37 |
+
[en_text, "Ed", "English"],
|
38 |
+
[pt_text, "Linda", "Português"]
|
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>"
|
42 |
|
43 |
my_inputs = [
|
44 |
gr.inputs.Textbox(lines=5, label="Input Text", default=lb_text),
|
45 |
+
gr.inputs.Radio(label="Speaker", choices = TTS_VOICES, default = "Judith"),
|
46 |
+
gr.inputs.Radio(label="Language", choices = TTS_LANGUAGES, default = "Lëtzebuergesch"),
|
47 |
]
|
48 |
|
49 |
my_outputs = gr.outputs.Audio(type="file", label="Output Audio")
|
|
|
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)
|
|
|
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
|