Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,26 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 3 |
-
import
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
print("Google Speech Recognition no pudo entender el audio")
|
| 19 |
-
except sr.RequestError as e:
|
| 20 |
-
print("No se pudo solicitar resultados del servicio de Google Speech Recognition; {0}".format(e))
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import pytesseract
|
| 4 |
+
from gtts import gTTS
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
+
# Funci贸n para convertir imagen a texto
|
| 8 |
+
def image_to_text(imagen):
|
| 9 |
+
texto = pytesseract.image_to_string(Image.open(imagen))
|
| 10 |
+
return texto
|
| 11 |
|
| 12 |
+
# Funci贸n para convertir texto a audio
|
| 13 |
+
def text_to_audio(texto):
|
| 14 |
+
audio = gTTS(text=texto, lang='es', slow=False)
|
| 15 |
+
audio.save("audio.mp3")
|
| 16 |
+
return "audio.mp3"
|
| 17 |
|
| 18 |
+
# Funci贸n que combina las dos funciones anteriores
|
| 19 |
+
def imagen_a_audio(imagen):
|
| 20 |
+
texto = image_to_text(imagen)
|
| 21 |
+
audio = text_to_audio(texto)
|
| 22 |
+
return audio
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
# Crear la interfaz de usuario con Gradio
|
| 25 |
+
iface = gr.Interface(fn=imagen_a_audio, inputs="Image", outputs="Audio")
|
| 26 |
+
iface.launch()
|