Luigi commited on
Commit
ceda09c
ยท
1 Parent(s): 4b51683

fix issue: player plays previous file after next audio is loaded

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +9 -0
src/streamlit_app.py CHANGED
@@ -22,6 +22,8 @@ if "utterances" not in st.session_state:
22
  st.session_state.utterances = []
23
  if "audio_base64" not in st.session_state:
24
  st.session_state.audio_base64 = None
 
 
25
 
26
  st.set_page_config(page_title="๐ŸŽ™๏ธ Moonshine ASR + LLM", layout="wide")
27
  st.title("๐ŸŽ™๏ธ Speech Summarization with Moonshine ASR & LLM")
@@ -69,6 +71,7 @@ with tab2:
69
  if st.button("Fetch from YouTube"):
70
  audio_path, status = fetch_audio(youtube_url, st.session_state.status)
71
  st.session_state.audio_path = audio_path
 
72
  st.session_state.status = status
73
 
74
  uploaded_file = st.file_uploader("Upload Audio", type=["mp3", "wav"])
@@ -78,8 +81,14 @@ with tab2:
78
  with open(temp_audio_path, "wb") as f:
79
  f.write(uploaded_file.getbuffer())
80
  st.session_state.audio_path = temp_audio_path
 
81
 
82
  with tab3:
 
 
 
 
 
83
  st.subheader("๐ŸŽค Transcription & Summary")
84
  st.markdown("---")
85
 
 
22
  st.session_state.utterances = []
23
  if "audio_base64" not in st.session_state:
24
  st.session_state.audio_base64 = None
25
+ if "prev_audio_path" not in st.session_state:
26
+ st.session_state.prev_audio_path = None
27
 
28
  st.set_page_config(page_title="๐ŸŽ™๏ธ Moonshine ASR + LLM", layout="wide")
29
  st.title("๐ŸŽ™๏ธ Speech Summarization with Moonshine ASR & LLM")
 
71
  if st.button("Fetch from YouTube"):
72
  audio_path, status = fetch_audio(youtube_url, st.session_state.status)
73
  st.session_state.audio_path = audio_path
74
+ st.session_state.audio_base64 = None # โœ… Clear base64
75
  st.session_state.status = status
76
 
77
  uploaded_file = st.file_uploader("Upload Audio", type=["mp3", "wav"])
 
81
  with open(temp_audio_path, "wb") as f:
82
  f.write(uploaded_file.getbuffer())
83
  st.session_state.audio_path = temp_audio_path
84
+ st.session_state.audio_base64 = None # โœ… Clear base64
85
 
86
  with tab3:
87
+
88
+ if st.session_state.audio_path and st.session_state.get("prev_audio_path") != st.session_state.audio_path:
89
+ st.session_state.audio_base64 = None
90
+ st.session_state.prev_audio_path = st.session_state.audio_path
91
+
92
  st.subheader("๐ŸŽค Transcription & Summary")
93
  st.markdown("---")
94