Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -26,14 +26,14 @@ def recognize_speech(audio_data, show_messages=True):
|
|
26 |
try:
|
27 |
audio_text = recognizer.recognize_google(audio, language="es-ES")
|
28 |
if show_messages:
|
29 |
-
st.subheader("
|
30 |
st.write(audio_text)
|
31 |
-
st.success("
|
32 |
except sr.UnknownValueError:
|
33 |
-
st.warning("
|
34 |
audio_text = ""
|
35 |
except sr.RequestError:
|
36 |
-
st.error("
|
37 |
audio_text = ""
|
38 |
|
39 |
return audio_text
|
@@ -94,7 +94,7 @@ def detect_voice_activity(audio_data):
|
|
94 |
|
95 |
return is_voice_active
|
96 |
|
97 |
-
def
|
98 |
st.write("Di la palabra XAMAN para empezar o DETENTE para procesar")
|
99 |
|
100 |
recording = mic_recorder(recording_container=st.empty(), auto_recording=True)
|
@@ -102,7 +102,7 @@ def def_main():
|
|
102 |
|
103 |
while audio_data is None:
|
104 |
if recording:
|
105 |
-
st.write("
|
106 |
audio_data = base64.b64decode(recording.split(",")[1])
|
107 |
audio_file = io.BytesIO(audio_data)
|
108 |
st.audio(audio_file, format="audio/wav")
|
@@ -117,6 +117,7 @@ def def_main():
|
|
117 |
f"""<audio autoplay="autoplay" controls="controls" src="data:audio/mp3;base64,{base64.b64encode(audio_file.read()).decode()}" type="audio/mp3" id="audio_player"></audio>""",
|
118 |
unsafe_allow_html=True)
|
119 |
else:
|
120 |
-
st.write("
|
121 |
|
122 |
-
|
|
|
|
26 |
try:
|
27 |
audio_text = recognizer.recognize_google(audio, language="es-ES")
|
28 |
if show_messages:
|
29 |
+
st.subheader("Texto reconocido:")
|
30 |
st.write(audio_text)
|
31 |
+
st.success("Voz reconocida.")
|
32 |
except sr.UnknownValueError:
|
33 |
+
st.warning("El audio no pudo ser reconocido. ¿Intentaste grabar algo?")
|
34 |
audio_text = ""
|
35 |
except sr.RequestError:
|
36 |
+
st.error("Error en la solicitud al servicio de reconocimiento de voz.")
|
37 |
audio_text = ""
|
38 |
|
39 |
return audio_text
|
|
|
94 |
|
95 |
return is_voice_active
|
96 |
|
97 |
+
def main():
|
98 |
st.write("Di la palabra XAMAN para empezar o DETENTE para procesar")
|
99 |
|
100 |
recording = mic_recorder(recording_container=st.empty(), auto_recording=True)
|
|
|
102 |
|
103 |
while audio_data is None:
|
104 |
if recording:
|
105 |
+
st.write("Escuchando...")
|
106 |
audio_data = base64.b64decode(recording.split(",")[1])
|
107 |
audio_file = io.BytesIO(audio_data)
|
108 |
st.audio(audio_file, format="audio/wav")
|
|
|
117 |
f"""<audio autoplay="autoplay" controls="controls" src="data:audio/mp3;base64,{base64.b64encode(audio_file.read()).decode()}" type="audio/mp3" id="audio_player"></audio>""",
|
118 |
unsafe_allow_html=True)
|
119 |
else:
|
120 |
+
st.write("Esperando entrada de voz...")
|
121 |
|
122 |
+
if __name__ == "__main__":
|
123 |
+
main()
|