Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,24 +4,23 @@ import io
|
|
4 |
from huggingface_hub import InferenceClient
|
5 |
from gtts import gTTS
|
6 |
import speech_recognition as sr
|
7 |
-
from streamlit-audiorecorder import st_audiorecorder
|
8 |
|
9 |
def capture_audio():
|
10 |
recognizer = sr.Recognizer()
|
11 |
|
12 |
with sr.Microphone() as source:
|
13 |
-
|
14 |
recognizer.adjust_for_ambient_noise(source)
|
15 |
audio = recognizer.listen(source, timeout=5)
|
16 |
|
17 |
try:
|
18 |
text = recognizer.recognize_google(audio, language="es-ES")
|
19 |
-
|
20 |
return audio, text
|
21 |
except sr.UnknownValueError:
|
22 |
-
|
23 |
except sr.RequestError as e:
|
24 |
-
|
25 |
|
26 |
return None, None
|
27 |
|
|
|
4 |
from huggingface_hub import InferenceClient
|
5 |
from gtts import gTTS
|
6 |
import speech_recognition as sr
|
|
|
7 |
|
8 |
def capture_audio():
|
9 |
recognizer = sr.Recognizer()
|
10 |
|
11 |
with sr.Microphone() as source:
|
12 |
+
st.write("Di algo...")
|
13 |
recognizer.adjust_for_ambient_noise(source)
|
14 |
audio = recognizer.listen(source, timeout=5)
|
15 |
|
16 |
try:
|
17 |
text = recognizer.recognize_google(audio, language="es-ES")
|
18 |
+
st.write("Has dicho: " + text)
|
19 |
return audio, text
|
20 |
except sr.UnknownValueError:
|
21 |
+
st.write("No se pudo entender el audio")
|
22 |
except sr.RequestError as e:
|
23 |
+
st.write("Error al solicitar los resultados: {0}".format(e))
|
24 |
|
25 |
return None, None
|
26 |
|