Spaces:
Sleeping
Sleeping
ALLARD Marc-Antoine
commited on
Commit
Β·
c9caa66
1
Parent(s):
51d35d6
- 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 |
-
"
|
394 |
type=['wav', 'mp3', 'flac', 'm4a'],
|
395 |
-
help="Supported formats: WAV, MP3, FLAC, M4A
|
396 |
)
|
397 |
|
398 |
if uploaded_file is not None:
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
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"""
|