Skip to content

Commit

Permalink
fix: Mac播放聲音問題 (#55
Browse files Browse the repository at this point in the history
  • Loading branch information
Keycatowo committed Sep 8, 2023
1 parent 51100cc commit 5b2c949
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pages/1-Basic_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
file = st.file_uploader("Upload your music library", type=["mp3", "wav", "ogg"])

if file is not None:
st.audio(file, format="audio/ogg")
st.audio(file, format=file.type)
st.subheader("File information")
st.write(f"File name: `{file.name}`", )
st.session_state["file_name"] = file.name
Expand Down Expand Up @@ -75,7 +75,7 @@
if use_segment:
with st.expander("聲音片段(Segment of the audio)"):
st.write(f"Selected segment: `{start_time}` ~ `{end_time}`, duration: `{end_time-start_time}`")
st.audio(y_sub, format="audio/ogg", sample_rate=sr)
st.audio(y_sub, format=file.type, sample_rate=sr)

use_plotly()

Expand Down
4 changes: 2 additions & 2 deletions pages/2-Pitch_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
file = st.file_uploader("Upload your music library", type=["mp3", "wav", "ogg"])

if file is not None:
st.audio(file, format="audio/ogg")
st.audio(file, format=file.type)
st.subheader("File information")
st.write(f"File name: `{file.name}`", )
st.session_state["file_name"] = file.name
Expand Down Expand Up @@ -79,7 +79,7 @@
if use_segment:
with st.expander("聲音片段(Segment of the audio)"):
st.write(f"Selected segment: `{start_time}` ~ `{end_time}`, duration: `{end_time-start_time}`")
st.audio(y_sub, format="audio/ogg", sample_rate=sr)
st.audio(y_sub, format=file.type, sample_rate=sr)

use_plotly()

Expand Down
8 changes: 4 additions & 4 deletions pages/3-Time_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
file = st.file_uploader("Upload your music library", type=["mp3", "wav", "ogg"])

if file is not None:
st.audio(file, format="audio/ogg")
st.audio(file, format=file.type)
st.subheader("File information")
st.write(f"File name: `{file.name}`", )
st.session_state["file_name"] = file.name
Expand Down Expand Up @@ -72,7 +72,7 @@
if use_segment:
with st.expander("聲音片段(Segment of the audio)"):
st.write(f"Selected segment: `{start_time}` ~ `{end_time}`, duration: `{end_time-start_time}`")
st.audio(y_sub, format="audio/ogg", sample_rate=sr)
st.audio(y_sub, format=file.type, sample_rate=sr)

use_plotly()

Expand Down Expand Up @@ -152,7 +152,7 @@
onset_remix_ratio = st.slider("Onset Click Volume Ratio", min_value=0.0, max_value=1.0, value=0.5, step=0.05)
y_onset_remix = y_onset_clicks*onset_remix_ratio + y_sub*(1-onset_remix_ratio)
y_onset_remix = y_onset_remix/np.max(np.abs(y_onset_remix))
st.audio(y_onset_remix, format="audio/ogg", sample_rate=sr)
st.audio(y_onset_remix, format="audio/wav", sample_rate=sr)


# onset_strength
Expand Down Expand Up @@ -230,7 +230,7 @@
beat_remix_ratio = st.slider("Beat Click Volume Ratio", min_value=0.0, max_value=1.0, value=0.5, step=0.05)
y_beat_remix = y_beat_clicks*beat_remix_ratio + y_sub*(1-beat_remix_ratio)
y_beat_remix = y_beat_remix/np.max(np.abs(y_beat_remix))
st.audio(y_beat_remix, format="audio/ogg", sample_rate=sr)
st.audio(y_beat_remix, format="audio/wav", sample_rate=sr)


# predominant_local_pulse
Expand Down
4 changes: 2 additions & 2 deletions pages/4-Chord_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
file = st.file_uploader("Upload your music library", type=["mp3", "wav", "ogg"])

if file is not None:
st.audio(file, format="audio/ogg")
st.audio(file, format=file.type)
st.subheader("File information")
st.write(f"File name: `{file.name}`", )
st.session_state["file_name"] = file.name
Expand Down Expand Up @@ -81,7 +81,7 @@
if use_segment:
with st.expander("聲音片段(Segment of the audio)"):
st.write(f"Selected segment: `{start_time}` ~ `{end_time}`, duration: `{end_time-start_time}`")
st.audio(y_sub, format="audio/ogg", sample_rate=sr)
st.audio(y_sub, format=file.type, sample_rate=sr)

#%%
if file is not None:
Expand Down
4 changes: 2 additions & 2 deletions pages/5-Structure_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
file = st.file_uploader("Upload your music library", type=["mp3", "wav", "ogg"])

if file is not None:
st.audio(file, format="audio/ogg")
st.audio(file, format=file.type)
st.subheader("File information")
st.write(f"File name: `{file.name}`", )
st.session_state["file_name"] = file.name
Expand Down Expand Up @@ -74,7 +74,7 @@
if use_segment:
with st.expander("聲音片段(Segment of the audio)"):
st.write(f"Selected segment: `{start_time}` ~ `{end_time}`, duration: `{end_time-start_time}`")
st.audio(y_sub, format="audio/ogg", sample_rate=sr)
st.audio(y_sub, format=file.type, sample_rate=sr)

#%%
if file is not None:
Expand Down
4 changes: 2 additions & 2 deletions pages/6-Timbre_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
file = st.file_uploader("Upload your music library", type=["mp3", "wav", "ogg"])

if file is not None:
st.audio(file, format="audio/ogg")
st.audio(file, format=file.type)
st.subheader("File information")
st.write(f"File name: `{file.name}`", )
st.session_state["file_name"] = file.name
Expand Down Expand Up @@ -77,7 +77,7 @@
if use_segment:
with st.expander("聲音片段(Segment of the audio)"):
st.write(f"Selected segment: `{start_time}` ~ `{end_time}`, duration: `{end_time-start_time}`")
st.audio(y_sub, format="audio/ogg", sample_rate=sr)
st.audio(y_sub, format=file.type, sample_rate=sr)

#%%
if file is not None:
Expand Down
4 changes: 2 additions & 2 deletions pages/7-Summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
file = st.file_uploader("Upload your music library", type=["mp3", "wav", "ogg"])

if file is not None:
st.audio(file, format="audio/ogg")
st.audio(file, format=file.type)
st.subheader("File information")
st.write(f"File name: `{file.name}`", )
st.session_state["file_name"] = file.name
Expand Down Expand Up @@ -96,7 +96,7 @@
if use_segment:
with st.expander("聲音片段(Segment of the audio)"):
st.write(f"Selected segment: `{start_time}` ~ `{end_time}`, duration: `{end_time-start_time}`")
st.audio(y_sub, format="audio/ogg", sample_rate=sr)
st.audio(y_sub, format=file.type, sample_rate=sr)



Expand Down

0 comments on commit 5b2c949

Please sign in to comment.