Spaces:
Running
Running
Fabio Grasso
commited on
Commit
·
c5d5e1b
1
Parent(s):
9866eca
fix: improve plotly
Browse files- app/helpers.py +1 -6
app/helpers.py
CHANGED
@@ -10,15 +10,10 @@ import numpy as np
|
|
10 |
def load_audio_segment(path: str, format: str) -> AudioSegment:
|
11 |
return AudioSegment.from_file(path, format=format)
|
12 |
|
13 |
-
#@st.cache_resource
|
14 |
def plot_audio(_audio_segment: AudioSegment, title: str = None) -> go.Figure:
|
15 |
samples = _audio_segment.get_array_of_samples()
|
16 |
-
arr = np.array(samples)
|
17 |
df = pd.DataFrame(arr)
|
18 |
fig = px.line(df, y=0, render_mode="webgl", line_shape="linear", width=1000, height=60, title=title)
|
19 |
fig.update_layout(xaxis_fixedrange=True, yaxis_fixedrange=True, yaxis_visible=False, xaxis_visible=False, hovermode=False, margin=dict(l=0, r=0, t=0, b=0))
|
20 |
-
#'font': {'size': 18},
|
21 |
-
#'xanchor': 'center',
|
22 |
-
#'yanchor': 'top'})
|
23 |
st.plotly_chart(fig, use_container_width=True)
|
24 |
-
#return fig
|
|
|
10 |
def load_audio_segment(path: str, format: str) -> AudioSegment:
|
11 |
return AudioSegment.from_file(path, format=format)
|
12 |
|
|
|
13 |
def plot_audio(_audio_segment: AudioSegment, title: str = None) -> go.Figure:
|
14 |
samples = _audio_segment.get_array_of_samples()
|
15 |
+
arr = np.array(samples[::20])
|
16 |
df = pd.DataFrame(arr)
|
17 |
fig = px.line(df, y=0, render_mode="webgl", line_shape="linear", width=1000, height=60, title=title)
|
18 |
fig.update_layout(xaxis_fixedrange=True, yaxis_fixedrange=True, yaxis_visible=False, xaxis_visible=False, hovermode=False, margin=dict(l=0, r=0, t=0, b=0))
|
|
|
|
|
|
|
19 |
st.plotly_chart(fig, use_container_width=True)
|
|