Spaces:
Sleeping
Sleeping
File size: 1,112 Bytes
5c5a283 9e26359 b767750 fac92f6 d6da658 9e26359 2b081ea 57714f9 fac92f6 57714f9 73ee3a5 57714f9 27903a3 57714f9 b767750 9e26359 57714f9 e13c1c8 27903a3 9e26359 5c5a283 9e26359 d6da658 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import gradio as gr
from transformers import pipeline
from gtts import gTTS
import IPython.display as ipd
#Definir 2 modelos uno de imagen a texto y otro de texto a audio que inyecta
# el resultado del primero modelo(texto generado) en la entrada del 2º modelo
# texto to audio
# Cargar el modelo que convierte imagen a texto
image_to_text_model = pipeline("image-classification")
text_to_audio_model = pipeline("text-to-speech")
# Función para la interfaz de Gradio
def image_to_audio(input_image):
# Convertir la imagen a texto
text_output = image_to_text_model(input_image)[0]['label']
print('text_output is :'+text_output)
# Generar audio a partir del texto
audio_output = text_to_audio_model(text_output)[0]['audio']
print('audio_output is :'+audio_output)
return audio_output
# Interfaz Gradio
iface = gr.Interface(
fn=image_to_audio,
inputs=gr.Image(type='pil'),
outputs=[gr.Textbox(value=image_to_text_model, label="Output"), gr.Audio()],
live=True,
interpretation="default",
capture_session=True
)
# Ejecutar la interfaz
iface.launch() |