Update app.py
Browse files
app.py
CHANGED
@@ -60,17 +60,16 @@ async def tts_interface(text, voice, rate, pitch, background_music):
|
|
60 |
return None, None, gr.Warning(warning)
|
61 |
|
62 |
# Verificar si se proporcion贸 un archivo de fondo musical
|
63 |
-
if background_music
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
-
#
|
67 |
-
|
68 |
-
output_file = tmp_file.name
|
69 |
-
add_background_music(speech_file, background_music, output_file)
|
70 |
-
|
71 |
-
# Eliminar el archivo temporal del speech original
|
72 |
-
os.remove(speech_file)
|
73 |
-
return output_file, None, None
|
74 |
|
75 |
async def create_demo():
|
76 |
voices = await get_voices()
|
@@ -99,7 +98,7 @@ async def create_demo():
|
|
99 |
gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value=""),
|
100 |
gr.Slider(minimum=-50, maximum=50, value=0, label="Speech Rate Adjustment (%)", step=1),
|
101 |
gr.Slider(minimum=-20, maximum=20, value=0, label="Pitch Adjustment (Hz)", step=1),
|
102 |
-
gr.Audio(label="Background Music", type="filepath"
|
103 |
],
|
104 |
outputs=[
|
105 |
gr.Audio(label="Generated Audio", type="filepath"),
|
|
|
60 |
return None, None, gr.Warning(warning)
|
61 |
|
62 |
# Verificar si se proporcion贸 un archivo de fondo musical
|
63 |
+
if background_music and background_music != "":
|
64 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
65 |
+
output_file = tmp_file.name
|
66 |
+
add_background_music(speech_file, background_music, output_file)
|
67 |
+
# Eliminar el archivo temporal del speech original
|
68 |
+
os.remove(speech_file)
|
69 |
+
return output_file, None, None
|
70 |
|
71 |
+
# Si no hay fondo musical, devolver el speech original
|
72 |
+
return speech_file, None, None
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
async def create_demo():
|
75 |
voices = await get_voices()
|
|
|
98 |
gr.Dropdown(choices=[""] + list(voices.keys()), label="Select Voice", value=""),
|
99 |
gr.Slider(minimum=-50, maximum=50, value=0, label="Speech Rate Adjustment (%)", step=1),
|
100 |
gr.Slider(minimum=-20, maximum=20, value=0, label="Pitch Adjustment (Hz)", step=1),
|
101 |
+
gr.Audio(label="Background Music", type="filepath") # Sin el argumento 'optional'
|
102 |
],
|
103 |
outputs=[
|
104 |
gr.Audio(label="Generated Audio", type="filepath"),
|