Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,7 @@ import IPython.display as ipd
|
|
10 |
|
11 |
# Cargar el modelo que convierte imagen a texto
|
12 |
image_to_text_model = pipeline("image-classification")
|
|
|
13 |
|
14 |
# Cargar el modelo que genera audio a partir de texto
|
15 |
# Funci贸n para convertir texto a audio
|
@@ -17,13 +18,22 @@ def text_to_audio(text):
|
|
17 |
tts = gTTS(text=text, lang='es')
|
18 |
tts.save('output.mp3')
|
19 |
return ipd.Audio('output.mp3')
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# Interfaz Gradio
|
23 |
iface = gr.Interface(
|
24 |
-
fn=
|
25 |
inputs=gr.Image(type='pil'),
|
26 |
-
outputs=[gr.Textbox(), gr.Audio(fn=
|
27 |
live=True,
|
28 |
interpretation="default",
|
29 |
capture_session=True
|
|
|
10 |
|
11 |
# Cargar el modelo que convierte imagen a texto
|
12 |
image_to_text_model = pipeline("image-classification")
|
13 |
+
text_to_audio_model = pipeline("text-to-speech")
|
14 |
|
15 |
# Cargar el modelo que genera audio a partir de texto
|
16 |
# Funci贸n para convertir texto a audio
|
|
|
18 |
tts = gTTS(text=text, lang='es')
|
19 |
tts.save('output.mp3')
|
20 |
return ipd.Audio('output.mp3')
|
21 |
+
|
22 |
+
# Funci贸n para la interfaz de Gradio
|
23 |
+
def image_to_audio(input_image):
|
24 |
+
# Convertir la imagen a texto
|
25 |
+
text_output = image_to_text_model(input_image)[0]['label']
|
26 |
+
|
27 |
+
# Generar audio a partir del texto
|
28 |
+
audio_output = text_to_audio_model(text_output)[0]['audio']
|
29 |
+
|
30 |
+
return audio_output
|
31 |
|
32 |
# Interfaz Gradio
|
33 |
iface = gr.Interface(
|
34 |
+
fn=image_to_audio,
|
35 |
inputs=gr.Image(type='pil'),
|
36 |
+
outputs=[gr.Textbox(), gr.Audio(fn=image_to_audio)],
|
37 |
live=True,
|
38 |
interpretation="default",
|
39 |
capture_session=True
|