Spaces:
Runtime error
Runtime error
Commit
·
bed109a
1
Parent(s):
18b6735
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,20 @@ def read_pdf(file):
|
|
13 |
text = extract_text(f)
|
14 |
return text
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
def main():
|
17 |
logging.basicConfig(level=logging.INFO)
|
18 |
repo_files = list_repo_files(repo_id="balacoon/tts")
|
@@ -20,26 +34,6 @@ def main():
|
|
20 |
model_name_dropdown = gr.inputs.Dropdown(label="Model", choices=model_files)
|
21 |
speaker = gr.inputs.Dropdown(label="Speaker", choices=[])
|
22 |
|
23 |
-
def set_model(model_name_str):
|
24 |
-
"""
|
25 |
-
Gets value from `model_name`, loads the model,
|
26 |
-
re-initializes the tts object, and gets a list of
|
27 |
-
speakers that the model supports and sets them to `speaker`.
|
28 |
-
"""
|
29 |
-
model_path = hf_hub_download(repo_id="balacoon/tts", filename=model_name_str)
|
30 |
-
global tts
|
31 |
-
tts = TTS(model_path)
|
32 |
-
speakers = tts.get_speakers()
|
33 |
-
value = speakers[-1]
|
34 |
-
speaker.choices = speakers
|
35 |
-
speaker.value = value
|
36 |
-
|
37 |
-
model_name = gr.Interface(
|
38 |
-
fn=set_model,
|
39 |
-
inputs=model_name_dropdown,
|
40 |
-
outputs=None
|
41 |
-
)
|
42 |
-
|
43 |
file_input = gr.inputs.File(label="Select a PDF File", type="file")
|
44 |
text = gr.outputs.Textbox()
|
45 |
|
@@ -65,7 +59,7 @@ def main():
|
|
65 |
|
66 |
iface = gr.Interface(
|
67 |
fn=synthesize_audio,
|
68 |
-
inputs=[file_input,
|
69 |
outputs=audio,
|
70 |
title="PDF TO SPEECH CONVERTER",
|
71 |
layout="rows",
|
|
|
13 |
text = extract_text(f)
|
14 |
return text
|
15 |
|
16 |
+
def set_model(model_name_str):
|
17 |
+
"""
|
18 |
+
Gets value from `model_name`, loads the model,
|
19 |
+
re-initializes the tts object, and gets a list of
|
20 |
+
speakers that the model supports and sets them to `speaker`.
|
21 |
+
"""
|
22 |
+
model_path = hf_hub_download(repo_id="balacoon/tts", filename=model_name_str)
|
23 |
+
global tts
|
24 |
+
tts = TTS(model_path)
|
25 |
+
speakers = tts.get_speakers()
|
26 |
+
value = speakers[-1]
|
27 |
+
speaker.choices = speakers
|
28 |
+
speaker.value = value
|
29 |
+
|
30 |
def main():
|
31 |
logging.basicConfig(level=logging.INFO)
|
32 |
repo_files = list_repo_files(repo_id="balacoon/tts")
|
|
|
34 |
model_name_dropdown = gr.inputs.Dropdown(label="Model", choices=model_files)
|
35 |
speaker = gr.inputs.Dropdown(label="Speaker", choices=[])
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
file_input = gr.inputs.File(label="Select a PDF File", type="file")
|
38 |
text = gr.outputs.Textbox()
|
39 |
|
|
|
59 |
|
60 |
iface = gr.Interface(
|
61 |
fn=synthesize_audio,
|
62 |
+
inputs=[file_input, model_name_dropdown, speaker],
|
63 |
outputs=audio,
|
64 |
title="PDF TO SPEECH CONVERTER",
|
65 |
layout="rows",
|