Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -96,28 +96,27 @@ def main():
|
|
96 |
available_microphones = list_available_microphones()
|
97 |
|
98 |
if available_microphones:
|
99 |
-
st.info("
|
100 |
-
|
101 |
-
st.info("Micr贸fono seleccionado: {}".format(
|
102 |
-
|
103 |
recognizer = sr.Recognizer()
|
104 |
-
audio_recording = sr.Microphone(device_index=
|
105 |
|
106 |
st.info("Habla para grabar")
|
107 |
with audio_recording as source:
|
108 |
recognizer.adjust_for_ambient_noise(source, duration=1)
|
109 |
audio_data = recognizer.listen(source, timeout=5)
|
110 |
-
|
111 |
st.success("Deteniendo la grabaci贸n...")
|
112 |
|
113 |
if audio_data:
|
114 |
st.audio(audio_data.frame_data, format="audio/wav")
|
115 |
-
audio_text = recognize_speech(device_index=
|
116 |
if audio_text:
|
117 |
-
output, audio_file = generate(audio_text, history=st.session_state.history)
|
118 |
|
119 |
-
if audio_text:
|
120 |
-
st.session_state.history.append((audio_text, output))
|
121 |
|
122 |
if audio_file is not None:
|
123 |
st.markdown(
|
|
|
96 |
available_microphones = list_available_microphones()
|
97 |
|
98 |
if available_microphones:
|
99 |
+
st.info("Micr贸fonos disponibles: {}".format(available_microphones))
|
100 |
+
selected_microphone = st.selectbox("Selecciona un micr贸fono", available_microphones)
|
101 |
+
st.info("Micr贸fono seleccionado: {}".format(selected_microphone))
|
|
|
102 |
recognizer = sr.Recognizer()
|
103 |
+
audio_recording = sr.Microphone(device_index=selected_microphone, sample_rate=16000, chunk_size=1024)
|
104 |
|
105 |
st.info("Habla para grabar")
|
106 |
with audio_recording as source:
|
107 |
recognizer.adjust_for_ambient_noise(source, duration=1)
|
108 |
audio_data = recognizer.listen(source, timeout=5)
|
109 |
+
|
110 |
st.success("Deteniendo la grabaci贸n...")
|
111 |
|
112 |
if audio_data:
|
113 |
st.audio(audio_data.frame_data, format="audio/wav")
|
114 |
+
audio_text = recognize_speech(device_index=selected_microphone)
|
115 |
if audio_text:
|
116 |
+
output, audio_file = generate(audio_text, history=st.session_state.history)
|
117 |
|
118 |
+
if audio_text:
|
119 |
+
st.session_state.history.append((audio_text, output))
|
120 |
|
121 |
if audio_file is not None:
|
122 |
st.markdown(
|