Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import HfApi
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import requests
|
| 5 |
+
from io import BytesIO
|
| 6 |
+
|
| 7 |
+
# Inicializa el modelo de OCR (Reconocimiento Óptico de Caracteres)
|
| 8 |
+
ocr_model = pipeline('text-recognition', model='your-model-name')
|
| 9 |
+
|
| 10 |
+
# Inicializa el modelo de TTS (Texto a Voz)
|
| 11 |
+
tts_model = pipeline('text-to-speech', model='your-model-name')
|
| 12 |
+
|
| 13 |
+
# Carga la imagen desde una URL
|
| 14 |
+
response = requests.get('https://example.com/your-image.jpg')
|
| 15 |
+
img = Image.open(BytesIO(response.content))
|
| 16 |
+
|
| 17 |
+
# Convierte la imagen a texto
|
| 18 |
+
text = ocr_model(img)
|
| 19 |
+
|
| 20 |
+
# Convierte el texto a audio
|
| 21 |
+
audio = tts_model(text)
|
| 22 |
+
|
| 23 |
+
# Guarda el audio en un archivo
|
| 24 |
+
with open('output.wav', 'wb') as f:
|
| 25 |
+
f.write(audio)
|