Skip to content

Commit

Permalink
feat: 開放plotly控制選項
Browse files Browse the repository at this point in the history
  • Loading branch information
Keycatowo committed Apr 23, 2023
1 parent dc09472 commit a6c341a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pages/1-Basic_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
import librosa
import pandas as pd
from src.st_helper import convert_df, get_shift, update_sessions
from src.st_helper import convert_df, get_shift, update_sessions, use_plotly
from src.basic_info import plot_waveform, signal_RMS_analysis, plot_spectrogram


Expand Down Expand Up @@ -77,7 +77,7 @@
st.write(f"Selected segment: `{start_time}` ~ `{end_time}`, duration: `{end_time-start_time}`")
st.audio(y_sub, format="audio/ogg", sample_rate=sr)


use_plotly()


#%% 功能分頁
Expand Down
3 changes: 2 additions & 1 deletion pages/2-Pitch_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import librosa
import pandas as pd
import seaborn as sns
from src.st_helper import convert_df, get_shift, update_sessions
from src.st_helper import convert_df, get_shift, update_sessions, use_plotly
from src.pitch_estimation import (
plot_mel_spectrogram,
plot_constant_q_transform,
Expand Down Expand Up @@ -81,6 +81,7 @@
st.write(f"Selected segment: `{start_time}` ~ `{end_time}`, duration: `{end_time-start_time}`")
st.audio(y_sub, format="audio/ogg", sample_rate=sr)

use_plotly()


#%% 功能分頁
Expand Down
4 changes: 3 additions & 1 deletion pages/3-Time_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import librosa
import pandas as pd
from src.beat_track import onsets_detection, plot_onset_strength, beat_analysis, predominant_local_pulse, static_tempo_estimation, plot_tempogram, onset_click_plot, beat_plot, plot_bpm
from src.st_helper import convert_df, get_shift, update_sessions
from src.st_helper import convert_df, get_shift, update_sessions, use_plotly
import numpy as np

st.title('Time Analysis')
Expand Down Expand Up @@ -73,6 +73,8 @@
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)

use_plotly()

#%% 功能區塊
if file is not None:
Expand Down
9 changes: 8 additions & 1 deletion src/st_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,11 @@ def warning_region(text="This is a warning"):
A warning region.
If the user does not select a file, the warning will be shown.
"""
st.warning(text, icon="⚠️")
st.warning(text, icon="⚠️")


def use_plotly():
st.session_state["use_plotly"] = st.sidebar.checkbox("Enable Dynamic Graphics", value=st.session_state["use_plotly"])
if st.session_state["use_plotly"]:
st.sidebar.info("Dynamic Graphics Enabled, more memory needed.\nWe will use Plotly to draw the figure if it is supported.")

0 comments on commit a6c341a

Please sign in to comment.