Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,19 +17,18 @@ pre_prompt_text = "eres una IA conductual, tus respuestas serán breves."
|
|
17 |
def recognize_speech(audio_data, show_messages=True):
|
18 |
recognizer = sr.Recognizer()
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
audio_text = ""
|
33 |
|
34 |
return audio_text
|
35 |
|
|
|
17 |
def recognize_speech(audio_data, show_messages=True):
|
18 |
recognizer = sr.Recognizer()
|
19 |
|
20 |
+
try:
|
21 |
+
audio_text = recognizer.recognize_google(audio_data, language="es-ES")
|
22 |
+
if show_messages:
|
23 |
+
st.subheader("Texto Reconocido:")
|
24 |
+
st.write(audio_text)
|
25 |
+
st.success("Reconocimiento de voz completado.")
|
26 |
+
except sr.UnknownValueError:
|
27 |
+
st.warning("No se pudo reconocer el audio. ¿Intentaste grabar algo?")
|
28 |
+
audio_text = ""
|
29 |
+
except sr.RequestError:
|
30 |
+
st.error("Hablame para comenzar!")
|
31 |
+
audio_text = ""
|
|
|
32 |
|
33 |
return audio_text
|
34 |
|