Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,14 +6,22 @@ from gtts import gTTS
|
|
6 |
from audiorecorder import audiorecorder
|
7 |
import speech_recognition as sr
|
8 |
|
9 |
-
def recognize_speech(audio_data):
|
10 |
recognizer = sr.Recognizer()
|
11 |
audio_recording = sr.AudioFile(audio_data)
|
12 |
|
13 |
with audio_recording as source:
|
14 |
audio = recognizer.record(source)
|
15 |
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
return audio_text
|
19 |
|
|
|
6 |
from audiorecorder import audiorecorder
|
7 |
import speech_recognition as sr
|
8 |
|
9 |
+
def recognize_speech(audio_data, show_messages):
|
10 |
recognizer = sr.Recognizer()
|
11 |
audio_recording = sr.AudioFile(audio_data)
|
12 |
|
13 |
with audio_recording as source:
|
14 |
audio = recognizer.record(source)
|
15 |
|
16 |
+
try:
|
17 |
+
audio_text = recognizer.recognize_google(audio, language="es-ES")
|
18 |
+
if show_messages:
|
19 |
+
st.subheader("Texto Reconocido:")
|
20 |
+
st.write(audio_text)
|
21 |
+
st.success("Reconocimiento de voz completado.")
|
22 |
+
except sr.UnknownValueError:
|
23 |
+
st.warning("No se pudo reconocer el audio. ¿Intentaste grabar algo?")
|
24 |
+
audio_text = ""
|
25 |
|
26 |
return audio_text
|
27 |
|