File size: 673 Bytes
fac92f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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)