Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,28 +12,22 @@ import IPython.display as ipd
|
|
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
|
17 |
-
def text_to_audio(text):
|
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()],
|
37 |
live=True,
|
38 |
interpretation="default",
|
39 |
capture_session=True
|
|
|
12 |
image_to_text_model = pipeline("image-classification")
|
13 |
text_to_audio_model = pipeline("text-to-speech")
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Funci贸n para la interfaz de Gradio
|
17 |
def image_to_audio(input_image):
|
18 |
# Convertir la imagen a texto
|
19 |
text_output = image_to_text_model(input_image)[0]['label']
|
20 |
+
print('text_output is :'+text_output)
|
21 |
# Generar audio a partir del texto
|
22 |
audio_output = text_to_audio_model(text_output)[0]['audio']
|
23 |
+
print('audio_output is :'+audio_output)
|
24 |
return audio_output
|
25 |
|
26 |
# Interfaz Gradio
|
27 |
iface = gr.Interface(
|
28 |
fn=image_to_audio,
|
29 |
inputs=gr.Image(type='pil'),
|
30 |
+
outputs=[gr.Textbox(value=image_to_text_model, label="Output"), gr.Audio()],
|
31 |
live=True,
|
32 |
interpretation="default",
|
33 |
capture_session=True
|