Spaces:
Sleeping
Sleeping
from transformers import pipeline | |
from PIL import Image | |
import requests | |
from io import BytesIO | |
# Inicializa el modelo de OCR (Reconocimiento Óptico de Caracteres) | |
ocr_model = pipeline('text-recognition', model='your-model-name') | |
# Inicializa el modelo de TTS (Texto a Voz) | |
tts_model = pipeline('text-to-speech', model='your-model-name') | |
# Carga la imagen desde una URL | |
response = requests.get('https://example.com/your-image.jpg') | |
img = Image.open(BytesIO(response.content)) | |
# Convierte la imagen a texto | |
text = ocr_model(img) | |
# Convierte el texto a audio | |
audio = tts_model(text) | |
# Guarda el audio en un archivo | |
with open('output.wav', 'wb') as f: | |
f.write(audio) |