Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from PIL import Image
|
|
3 |
import google.generativeai as genai
|
4 |
from gtts import gTTS
|
5 |
import os
|
|
|
6 |
|
7 |
# Configuraci贸n de la p谩gina de Streamlit
|
8 |
st.set_page_config(page_title="馃 ChatBot", layout="wide")
|
@@ -19,10 +20,18 @@ def procesar_texto(texto):
|
|
19 |
def procesar_imagen(imagen):
|
20 |
genai.configure(api_key=api_key)
|
21 |
modelo = genai.GenerativeModel('gemini-1.5-pro-latest')
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
26 |
|
27 |
def hablar_texto(texto):
|
28 |
try:
|
|
|
3 |
import google.generativeai as genai
|
4 |
from gtts import gTTS
|
5 |
import os
|
6 |
+
import io
|
7 |
|
8 |
# Configuraci贸n de la p谩gina de Streamlit
|
9 |
st.set_page_config(page_title="馃 ChatBot", layout="wide")
|
|
|
20 |
def procesar_imagen(imagen):
|
21 |
genai.configure(api_key=api_key)
|
22 |
modelo = genai.GenerativeModel('gemini-1.5-pro-latest')
|
23 |
+
|
24 |
+
# Convertir la imagen a bytes
|
25 |
+
imagen_bytes = io.BytesIO()
|
26 |
+
imagen.save(imagen_bytes, format='PNG')
|
27 |
+
imagen_bytes.seek(0)
|
28 |
|
29 |
+
try:
|
30 |
+
# Procesar imagen (esto depende de la API que uses, adaptarlo si es necesario)
|
31 |
+
respuesta = modelo.generate_content(imagen_bytes.read())
|
32 |
+
return respuesta.text
|
33 |
+
except Exception as e:
|
34 |
+
return f"Error al procesar la imagen: {e}"
|
35 |
|
36 |
def hablar_texto(texto):
|
37 |
try:
|