Update app.py
Browse files
app.py
CHANGED
@@ -2,15 +2,13 @@ import streamlit as st
|
|
2 |
from PIL import Image
|
3 |
import google.generativeai as genai
|
4 |
from gtts import gTTS
|
5 |
-
import os
|
6 |
import io
|
7 |
import base64
|
8 |
|
9 |
# Configuración de la página de Streamlit
|
10 |
st.set_page_config(page_title="🤖 Soph-IA", layout="wide")
|
11 |
|
12 |
-
|
13 |
-
api_key = st.secrets["API_KEY"] # Accede al secreto
|
14 |
|
15 |
# Estilo CSS para diseño atractivo
|
16 |
st.markdown("""
|
@@ -47,7 +45,7 @@ st.markdown("""
|
|
47 |
</style>
|
48 |
""", unsafe_allow_html=True)
|
49 |
|
50 |
-
# Respuestas automatizadas
|
51 |
def respuestas_automatizadas(texto):
|
52 |
texto = texto.lower()
|
53 |
respuestas = {
|
@@ -94,11 +92,11 @@ def procesar_imagen(imagen):
|
|
94 |
def hablar_texto(texto):
|
95 |
try:
|
96 |
tts = gTTS(text=texto, lang='es', slow=False)
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
except Exception as e:
|
103 |
st.error("Hubo un error al generar el audio. Por favor, recarga la página y vuelve a intentar.")
|
104 |
return None
|
@@ -106,7 +104,7 @@ def hablar_texto(texto):
|
|
106 |
# Título centrado
|
107 |
st.markdown("<h1>🤖 ¡Bienvenido a Soph-IA!</h1>", unsafe_allow_html=True)
|
108 |
|
109 |
-
# Explicación técnica
|
110 |
st.markdown("""
|
111 |
<p style='text-align: justify;'>
|
112 |
Soy <strong>Soph-IA</strong>, una inteligencia artificial basada en redes neuronales profundas, derivada de la arquitectura
|
|
|
2 |
from PIL import Image
|
3 |
import google.generativeai as genai
|
4 |
from gtts import gTTS
|
|
|
5 |
import io
|
6 |
import base64
|
7 |
|
8 |
# Configuración de la página de Streamlit
|
9 |
st.set_page_config(page_title="🤖 Soph-IA", layout="wide")
|
10 |
|
11 |
+
api_key = st.secrets["API_KEY"]
|
|
|
12 |
|
13 |
# Estilo CSS para diseño atractivo
|
14 |
st.markdown("""
|
|
|
45 |
</style>
|
46 |
""", unsafe_allow_html=True)
|
47 |
|
48 |
+
# Respuestas automatizadas
|
49 |
def respuestas_automatizadas(texto):
|
50 |
texto = texto.lower()
|
51 |
respuestas = {
|
|
|
92 |
def hablar_texto(texto):
|
93 |
try:
|
94 |
tts = gTTS(text=texto, lang='es', slow=False)
|
95 |
+
audio_file = io.BytesIO()
|
96 |
+
tts.save(audio_file)
|
97 |
+
audio_file.seek(0)
|
98 |
+
audio_base64 = base64.b64encode(audio_file.read()).decode()
|
99 |
+
return f"data:audio/mp3;base64,{audio_base64}"
|
100 |
except Exception as e:
|
101 |
st.error("Hubo un error al generar el audio. Por favor, recarga la página y vuelve a intentar.")
|
102 |
return None
|
|
|
104 |
# Título centrado
|
105 |
st.markdown("<h1>🤖 ¡Bienvenido a Soph-IA!</h1>", unsafe_allow_html=True)
|
106 |
|
107 |
+
# Explicación técnica
|
108 |
st.markdown("""
|
109 |
<p style='text-align: justify;'>
|
110 |
Soy <strong>Soph-IA</strong>, una inteligencia artificial basada en redes neuronales profundas, derivada de la arquitectura
|