cadasme commited on
Commit
9234e12
1 Parent(s): 06b1b51

feat: incluye spinner loading icon y output block para los resultados

Browse files
Files changed (1) hide show
  1. app.py +33 -29
app.py CHANGED
@@ -27,33 +27,37 @@ def convert_mp3_to_wav(mp3_path):
27
  audio.export(wav_path, format="wav")
28
  return wav_path
29
 
30
- # Streamlit App
31
- st.title('Transcriptor de Audio')
32
-
33
- uploaded_file = st.file_uploader("Sube tu archivo de audio para transcribir", type=['wav', 'mp3'])
34
-
35
- if uploaded_file is not None:
36
- file_details = {"FileName":uploaded_file.name, "FileType":uploaded_file.type, "FileSize":uploaded_file.size}
37
- st.write(file_details)
38
-
39
- # Save uploaded file to temp directory
40
- file_path = os.path.join("temp", uploaded_file.name)
41
- with open(file_path, "wb") as f:
42
- f.write(uploaded_file.getbuffer())
43
-
44
- st.write("Archivo de audio cargado correctamente. Por favor, selecciona el método de transcripción.")
45
- transcription_method = st.selectbox('Escoge el método de transcripción', ('OpenAI Whisper', 'Google Speech API'))
46
-
47
- if transcription_method == 'OpenAI Whisper':
48
- model_name = st.selectbox('Escoge el modelo de Whisper', ('base', 'small', 'medium', 'large', 'tiny'))
49
- elif transcription_method == 'Google Speech API' and file_path.endswith('.mp3'):
50
- # Convert mp3 to wav if Google Speech API is selected and file is in mp3 format
51
- file_path = convert_mp3_to_wav(file_path)
52
-
53
- if st.button('Transcribir'):
54
- if transcription_method == 'OpenAI Whisper':
55
- transcript = transcribe_whisper(model_name, file_path)
56
- else:
57
- transcript = transcribe_speech_recognition(file_path)
58
 
59
- st.write(transcript)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  audio.export(wav_path, format="wav")
28
  return wav_path
29
 
30
+ def main():
31
+ st.title('Transcriptor de Audio')
32
+
33
+ uploaded_file = st.file_uploader("Sube tu archivo de audio para transcribir", type=['wav', 'mp3'])
34
+
35
+ if uploaded_file is not None:
36
+ file_details = {"FileName":uploaded_file.name, "FileType":uploaded_file.type, "FileSize":uploaded_file.size}
37
+ st.write(file_details)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
+ # Save uploaded file to temp directory
40
+ file_path = os.path.join("temp", uploaded_file.name)
41
+ with open(file_path, "wb") as f:
42
+ f.write(uploaded_file.getbuffer())
43
+
44
+ st.write("Archivo de audio cargado correctamente. Por favor, selecciona el método de transcripción.")
45
+ transcription_method = st.selectbox('Escoge el método de transcripción', ('OpenAI Whisper', 'Google Speech API'))
46
+
47
+ if transcription_method == 'OpenAI Whisper':
48
+ model_name = st.selectbox('Escoge el modelo de Whisper', ('base', 'small', 'medium', 'large', 'tiny'))
49
+ elif transcription_method == 'Google Speech API' and file_path.endswith('.mp3'):
50
+ # Convert mp3 to wav if Google Speech API is selected and file is in mp3 format
51
+ file_path = convert_mp3_to_wav(file_path)
52
+
53
+ if st.button('Transcribir'):
54
+ with st.spinner('Transcribiendo...'):
55
+ if transcription_method == 'OpenAI Whisper':
56
+ transcript = transcribe_whisper(model_name, file_path)
57
+ else:
58
+ transcript = transcribe_speech_recognition(file_path)
59
+
60
+ st.text_area('Resultado de la Transcripción:', transcript, height=200)
61
+
62
+ if __name__ == "__main__":
63
+ main()