ALLARD Marc-Antoine commited on
Commit
c9caa66
Β·
1 Parent(s): 51d35d6
Files changed (1) hide show
  1. src/streamlit_app.py +22 -39
src/streamlit_app.py CHANGED
@@ -390,49 +390,32 @@ def show_home_page():
390
  st.info("πŸ’‘ **Tip for Hugging Face Spaces:** Large files (>10MB) may fail to upload. Try smaller audio files or compress your audio if you encounter issues.")
391
 
392
  uploaded_file = st.file_uploader(
393
- "Upload an audio file",
394
  type=['wav', 'mp3', 'flac', 'm4a'],
395
- help="Supported formats: WAV, MP3, FLAC, M4A. Keep files under 10MB for best compatibility on Hugging Face Spaces."
396
  )
397
 
398
  if uploaded_file is not None:
399
- try:
400
- # Read file data
401
- audio_data = uploaded_file.read()
402
-
403
- # Check file size (warn if >10MB for HF Spaces)
404
- file_size_mb = len(audio_data) / (1024 * 1024)
405
- if file_size_mb > 10:
406
- st.warning(f"⚠️ File size: {file_size_mb:.1f}MB. Large files may cause issues on Hugging Face Spaces.")
407
-
408
- # Store in session state
409
- st.session_state.audio_file = audio_data
410
-
411
- # Get duration
412
- st.session_state.audio_duration = get_audio_duration(audio_data)
413
-
414
- st.success(f"βœ… Audio file uploaded successfully! ({file_size_mb:.1f}MB)")
415
-
416
- if st.session_state.audio_duration > 0:
417
- st.info(f"Duration: {format_time(st.session_state.audio_duration)}")
418
-
419
- # Show audio player
420
- st.subheader("Audio Preview")
421
- audio_html = create_audio_player_html(st.session_state.audio_file)
422
- st.components.v1.html(audio_html, height=120)
423
-
424
- # Continue button
425
- if st.button("Continue to Transcription β†’", type="primary"):
426
- st.session_state.current_page = "transcription"
427
- st.rerun()
428
-
429
- except Exception as e:
430
- st.error(f"❌ Error processing audio file: {str(e)}")
431
- st.error("This might be due to:")
432
- st.error("- File format not supported")
433
- st.error("- File too large for Hugging Face Spaces")
434
- st.error("- Corrupted audio file")
435
- st.info("Try converting your audio to WAV format and reducing the file size.")
436
 
437
  def show_transcription_page():
438
  """Transcription page - text annotation"""
 
390
  st.info("πŸ’‘ **Tip for Hugging Face Spaces:** Large files (>10MB) may fail to upload. Try smaller audio files or compress your audio if you encounter issues.")
391
 
392
  uploaded_file = st.file_uploader(
393
+ "Choose an audio file",
394
  type=['wav', 'mp3', 'flac', 'm4a'],
395
+ help="Supported formats: WAV, MP3, FLAC, M4A"
396
  )
397
 
398
  if uploaded_file is not None:
399
+ st.session_state.audio_file = uploaded_file.read()
400
+
401
+ # Save temporary file to get duration
402
+ with tempfile.NamedTemporaryFile(delete=False, suffix='.wav') as tmp_file:
403
+ tmp_file.write(st.session_state.audio_file)
404
+ st.session_state.audio_duration = get_audio_duration(tmp_file.name)
405
+ os.unlink(tmp_file.name)
406
+
407
+ st.success(f"βœ… Audio file uploaded successfully!")
408
+ st.info(f"Duration: {format_time(st.session_state.audio_duration)}")
409
+
410
+ # Show audio player
411
+ st.subheader("Audio Preview")
412
+ audio_html = create_audio_player_html(st.session_state.audio_file)
413
+ st.components.v1.html(audio_html, height=120)
414
+
415
+ # Continue button
416
+ if st.button("Continue to Transcription β†’", type="primary"):
417
+ st.session_state.current_page = "transcription"
418
+ st.rerun()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
 
420
  def show_transcription_page():
421
  """Transcription page - text annotation"""