Spaces:
Runtime error
Runtime error
Commit
·
206a641
1
Parent(s):
6731d14
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,12 +7,14 @@ from balacoon_tts import TTS
|
|
| 7 |
|
| 8 |
# Global TTS module, initialized from a selected model
|
| 9 |
tts = None
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def read_pdf(file):
|
| 12 |
text = extract_text(file.name)
|
| 13 |
return text
|
| 14 |
|
| 15 |
-
def synthesize_audio(file,
|
| 16 |
text_str = read_pdf(file)
|
| 17 |
if len(text_str) > 1024:
|
| 18 |
text_str = text_str[:1024]
|
|
@@ -28,19 +30,17 @@ def main():
|
|
| 28 |
|
| 29 |
def set_model(model_name_str: str):
|
| 30 |
model_path = hf_hub_download(repo_id="balacoon/tts", filename=model_name_str)
|
| 31 |
-
global tts
|
| 32 |
tts = TTS(model_path)
|
| 33 |
speakers = tts.get_speakers()
|
| 34 |
default_speaker = speakers[-1]
|
| 35 |
-
speaker_dropdown.choices = speakers
|
| 36 |
-
return speakers, default_speaker
|
| 37 |
|
| 38 |
-
speaker_dropdown = gr.inputs.Dropdown(label="Speaker", choices=
|
| 39 |
|
| 40 |
audio = gr.outputs.Audio(label="Generated Audio", type="numpy")
|
| 41 |
|
| 42 |
-
def generate_audio(file,
|
| 43 |
-
return synthesize_audio(file,
|
| 44 |
|
| 45 |
iface = gr.Interface(
|
| 46 |
fn=generate_audio,
|
|
@@ -51,7 +51,7 @@ def main():
|
|
| 51 |
debug=True
|
| 52 |
)
|
| 53 |
|
| 54 |
-
model_name_dropdown.
|
| 55 |
|
| 56 |
iface.launch()
|
| 57 |
|
|
|
|
| 7 |
|
| 8 |
# Global TTS module, initialized from a selected model
|
| 9 |
tts = None
|
| 10 |
+
speakers = []
|
| 11 |
+
default_speaker = None
|
| 12 |
|
| 13 |
def read_pdf(file):
|
| 14 |
text = extract_text(file.name)
|
| 15 |
return text
|
| 16 |
|
| 17 |
+
def synthesize_audio(file, speaker_str):
|
| 18 |
text_str = read_pdf(file)
|
| 19 |
if len(text_str) > 1024:
|
| 20 |
text_str = text_str[:1024]
|
|
|
|
| 30 |
|
| 31 |
def set_model(model_name_str: str):
|
| 32 |
model_path = hf_hub_download(repo_id="balacoon/tts", filename=model_name_str)
|
| 33 |
+
global tts, speakers, default_speaker
|
| 34 |
tts = TTS(model_path)
|
| 35 |
speakers = tts.get_speakers()
|
| 36 |
default_speaker = speakers[-1]
|
|
|
|
|
|
|
| 37 |
|
| 38 |
+
speaker_dropdown = gr.inputs.Dropdown(label="Speaker", choices=speakers)
|
| 39 |
|
| 40 |
audio = gr.outputs.Audio(label="Generated Audio", type="numpy")
|
| 41 |
|
| 42 |
+
def generate_audio(file, speaker_str):
|
| 43 |
+
return synthesize_audio(file, speaker_str)
|
| 44 |
|
| 45 |
iface = gr.Interface(
|
| 46 |
fn=generate_audio,
|
|
|
|
| 51 |
debug=True
|
| 52 |
)
|
| 53 |
|
| 54 |
+
model_name_dropdown.set_action(set_model)
|
| 55 |
|
| 56 |
iface.launch()
|
| 57 |
|