File size: 704 Bytes
5c5a283
9853375
 
 
 
fac92f6
9853375
 
 
 
d6da658
9853375
 
 
 
 
fac92f6
9853375
 
 
 
 
5c5a283
9853375
 
 
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
import gradio as gr
from PIL import Image
import pytesseract
from gtts import gTTS
import os

# Funci贸n para convertir imagen a texto
def image_to_text(imagen):
    texto = pytesseract.image_to_string(Image.open(imagen))
    return texto

# Funci贸n para convertir texto a audio
def text_to_audio(texto):
    audio = gTTS(text=texto, lang='es', slow=False)
    audio.save("audio.mp3")
    return "audio.mp3"

# Funci贸n que combina las dos funciones anteriores
def imagen_a_audio(imagen):
    texto = image_to_text(imagen)
    audio = text_to_audio(texto)
    return audio

# Crear la interfaz de usuario con Gradio
iface = gr.Interface(fn=imagen_a_audio, inputs="Image", outputs="Audio")
iface.launch()