Spaces:
Sleeping
Sleeping
working
Browse files
app.py
CHANGED
@@ -23,11 +23,11 @@ def transcribe_whisper(model_name, file_path):
|
|
23 |
def transcribe_speech_recognition(file_path):
|
24 |
r = sr.Recognizer()
|
25 |
with sr.AudioFile(file_path) as source:
|
26 |
-
r.adjust_for_ambient_noise(source, duration=0.
|
27 |
audio = r.record(source)
|
28 |
|
29 |
try:
|
30 |
-
result = r.recognize_google(audio, language='
|
31 |
return result
|
32 |
except sr.UnknownValueError:
|
33 |
return "No se pudo reconocer ningún texto en el audio."
|
@@ -66,6 +66,9 @@ def main():
|
|
66 |
# Choose the transcription method and model
|
67 |
option = st.selectbox('Escoger Modelo de Transcripción', ('Subir un archivo', 'Grabar audio en tiempo real'))
|
68 |
transcription_method = st.selectbox('Escoge el método de transcripción', ('OpenAI Whisper', 'Google Speech API'))
|
|
|
|
|
|
|
69 |
if transcription_method == 'OpenAI Whisper':
|
70 |
model_name = st.selectbox('Escoge el modelo de Whisper', ('base', 'small', 'medium', 'large', 'tiny'))
|
71 |
|
@@ -76,11 +79,7 @@ def main():
|
|
76 |
handle_uploaded_file(uploaded_file, transcription_method, model_name)
|
77 |
|
78 |
elif option == 'Grabar audio en tiempo real':
|
79 |
-
|
80 |
-
# duration = st.slider("Selecciona la duración de la grabación (segundos)", 1, 10, 5)
|
81 |
-
# st.write("Duración de la grabación:", duration, "segundos")
|
82 |
-
|
83 |
-
audio_bytes = audio_recorder(pause_threshold=duration, sample_rate=16_000)
|
84 |
|
85 |
if audio_bytes:
|
86 |
st.write("Grabación finalizada. Transcribiendo...")
|
@@ -95,5 +94,6 @@ def main():
|
|
95 |
|
96 |
st.text_area('Resultado de la Transcripción:', transcript, height=200)
|
97 |
|
|
|
98 |
if __name__ == "__main__":
|
99 |
main()
|
|
|
23 |
def transcribe_speech_recognition(file_path):
|
24 |
r = sr.Recognizer()
|
25 |
with sr.AudioFile(file_path) as source:
|
26 |
+
r.adjust_for_ambient_noise(source, duration=0.25) # Adjust ambient noise threshold
|
27 |
audio = r.record(source)
|
28 |
|
29 |
try:
|
30 |
+
result = r.recognize_google(audio, language='es')
|
31 |
return result
|
32 |
except sr.UnknownValueError:
|
33 |
return "No se pudo reconocer ningún texto en el audio."
|
|
|
66 |
# Choose the transcription method and model
|
67 |
option = st.selectbox('Escoger Modelo de Transcripción', ('Subir un archivo', 'Grabar audio en tiempo real'))
|
68 |
transcription_method = st.selectbox('Escoge el método de transcripción', ('OpenAI Whisper', 'Google Speech API'))
|
69 |
+
|
70 |
+
model_name = None # Initialize model_name with a default value
|
71 |
+
|
72 |
if transcription_method == 'OpenAI Whisper':
|
73 |
model_name = st.selectbox('Escoge el modelo de Whisper', ('base', 'small', 'medium', 'large', 'tiny'))
|
74 |
|
|
|
79 |
handle_uploaded_file(uploaded_file, transcription_method, model_name)
|
80 |
|
81 |
elif option == 'Grabar audio en tiempo real':
|
82 |
+
audio_bytes = audio_recorder(pause_threshold=5, sample_rate=16_000)
|
|
|
|
|
|
|
|
|
83 |
|
84 |
if audio_bytes:
|
85 |
st.write("Grabación finalizada. Transcribiendo...")
|
|
|
94 |
|
95 |
st.text_area('Resultado de la Transcripción:', transcript, height=200)
|
96 |
|
97 |
+
|
98 |
if __name__ == "__main__":
|
99 |
main()
|