Fabio Grasso commited on
Commit
334bc59
β€’
1 Parent(s): 311dc33

fix: reduce examples

Browse files
app/examples.py CHANGED
@@ -8,7 +8,7 @@ def _load_example(name: str):
8
  cols = st.columns(2)
9
  with cols[0]:
10
  auseg = load_audio_segment(f"samples/{name}", "mp3")
11
- plot_audio(auseg)
12
  with cols[1]:
13
  audio_file = open(f"samples/{name}", "rb")
14
  audio_bytes = audio_file.read()
@@ -28,7 +28,7 @@ def _load_example(name: str):
28
  cols = st.columns(2)
29
  with cols[0]:
30
  auseg = load_audio_segment(f"samples/{name.split('.mp3')[0]}/{file}", "mp3")
31
- plot_audio(auseg)
32
  with cols[1]:
33
  audio_file = open(f"samples/{name.split('.mp3')[0]}/{file}", "rb")
34
  audio_bytes = audio_file.read()
@@ -37,18 +37,18 @@ def _load_example(name: str):
37
 
38
  def show_examples():
39
  with st.columns([2, 8, 1])[1]:
40
- selection = st.selectbox("Select an example music to quickly see results", ["Push - Coma Media", "Indie Rock", "Something About You - Marilyn Ford"])
41
- if selection == "Push - Coma Media":
42
- _load_example("push-coma-media.mp3")
43
- link = "https://pixabay.com/users/coma-media-24399569/"
44
  st.markdown(
45
- f"""Music by <a href="{link}">Coma-Media</a> from <a href="{link}">Pixabay</a>""",
46
  unsafe_allow_html=True)
47
  elif selection == "Indie Rock":
48
  _load_example("indie-rock.mp3")
49
  link = "https://pixabay.com/music/indie-rock-112771/"
50
  st.markdown(
51
- f"""Music by <a href={link}">Music_Unlimited</a> from <a href="{link}">Pixabay</a>""",
52
  unsafe_allow_html=True)
53
  elif selection == "Something About You - Marilyn Ford":
54
  _load_example("something-about-you-marilyn-ford.mp3")
 
8
  cols = st.columns(2)
9
  with cols[0]:
10
  auseg = load_audio_segment(f"samples/{name}", "mp3")
11
+ plot_audio(auseg, step=50)
12
  with cols[1]:
13
  audio_file = open(f"samples/{name}", "rb")
14
  audio_bytes = audio_file.read()
 
28
  cols = st.columns(2)
29
  with cols[0]:
30
  auseg = load_audio_segment(f"samples/{name.split('.mp3')[0]}/{file}", "mp3")
31
+ plot_audio(auseg, step=50)
32
  with cols[1]:
33
  audio_file = open(f"samples/{name.split('.mp3')[0]}/{file}", "rb")
34
  audio_bytes = audio_file.read()
 
37
 
38
  def show_examples():
39
  with st.columns([2, 8, 1])[1]:
40
+ selection = st.selectbox("Select an example music to quickly see results", ["Something About You - Marilyn Ford", "Broke Me - FASSounds", "Indie Rock"])
41
+ if selection == "Broke Me - FASSounds":
42
+ _load_example("broke-me-fassounds.mp3")
43
+ link = "https://pixabay.com/users/fassounds-3433550/"
44
  st.markdown(
45
+ f"""Music by <a href="{link}">FASSounds</a> from <a href="{link}">Pixabay</a>""",
46
  unsafe_allow_html=True)
47
  elif selection == "Indie Rock":
48
  _load_example("indie-rock.mp3")
49
  link = "https://pixabay.com/music/indie-rock-112771/"
50
  st.markdown(
51
+ f"""Music by <a href="{link}">Music_Unlimited</a> from <a href="{link}">Pixabay</a>""",
52
  unsafe_allow_html=True)
53
  elif selection == "Something About You - Marilyn Ford":
54
  _load_example("something-about-you-marilyn-ford.mp3")
app/helpers.py CHANGED
@@ -10,9 +10,9 @@ import numpy as np
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))
 
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, step = 20) -> go.Figure:
14
  samples = _audio_segment.get_array_of_samples()
15
+ arr = np.array(samples[::step])
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))
samples/{push-coma-media.mp3 β†’ broke-me-fassounds.mp3} RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:92058637b42733b61b5c2f6c9fa3367919eb3a43cea5415893a56f39927ac528
3
- size 3354540
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8cee8d6d724eec3ae3dc29d7b9581009057da459bf0ab2b1428dc84f532afe4a
3
+ size 961350
samples/{push-coma-media β†’ broke-me-fassounds}/bass.mp3 RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b235327107bae1aff207b649da4a9a8679dee8cb25aae66655529dbd5568cc62
3
- size 4194220
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2b8f2db0ee38dffbc1ed4a1bb584d7e4e77e9daab9179c75fd51bd5fc10ad47
3
+ size 1201632
samples/{push-coma-media β†’ broke-me-fassounds}/drums.mp3 RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2f1dec9e42305f0db9fbfe6b2a409bd3cf158b7402680571ad72fd746b9c5bb6
3
- size 4194220
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a6a402c1e95b3bc430e0bd2a0c0d5397e273b86a714eb95194571be261255006
3
+ size 1201632
samples/{push-coma-media β†’ broke-me-fassounds}/other.mp3 RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:31d6b52b48a873126d7e8bb8cb5809d94f7168e7bfddd1afd86abddc50cca1fb
3
- size 4194220
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a9e96cef31cf77019630ca42345cb1ccd68f1145202ac35353d8ccc33a3bf5b7
3
+ size 1201632
samples/{push-coma-media β†’ broke-me-fassounds}/vocals.mp3 RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:94e7fb8f4330b0eea772fd8cff766d4dc986163ccda4dab0b5837fc6ee5851c8
3
- size 4194220
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7e5d2e12b4f6fc41ae44c4bf71fc91cfa591cf670a1f87661d4907737ffd66c
3
+ size 1201632
samples/indie-rock.mp3 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:775c80bbf15e53083191d62ca6f9350a383ec48a8d09878372875cbc3b68423e
3
- size 4578324
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e57a788afacb71dcddc019c61190c99d2ee9722d921ca072033393bea021930c
3
+ size 1202721
samples/indie-rock/bass.mp3 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:100ef5359158ae7810e2c6f20d7d83d0b276b528c8888cd956f61410faf34c9a
3
- size 5723951
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:519d440101f10b0f23574480b366c5d35ce46b8e5224396197bad894e6690470
3
+ size 1201632
samples/indie-rock/drums.mp3 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:3c873bc4958cb02f8e338c2958d83c36525f1d5a668c48dd9200d8822a37a6e7
3
- size 5723951
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:736a94b73cb3d3dc89ce72165d4efd70a8d7c25d6eb432883ea164635dbf1de0
3
+ size 1201632
samples/indie-rock/other.mp3 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d06239063e7e14b70a8b794635ddbe5d30b5fea86c317e885c680bb7399b012b
3
- size 5723951
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d7b82814b2123c9b5014481a68da0579cbe8a37763e48b8fec2532396485f4f4
3
+ size 1201632
samples/indie-rock/vocals.mp3 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a9b0f4ce89506fb7001a5f676ac90f930a46c179779251284129202a39f8903f
3
- size 5723951
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c2dc3d8f61972599f3a20fb831c9215e07d81b3e5d2ec76724eb9fc741172985
3
+ size 1201632
samples/something-about-you-marilyn-ford.mp3 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:8d8072ba713f89116c703e24272ecbc4435f2309ab6637f4d32175e75257b530
3
- size 6723291
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a05321de34f0d6e325c14e8cb61d083b6969ca6b1735b8178989b74fea3955d
3
+ size 1202721
samples/something-about-you-marilyn-ford/bass.mp3 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:068a054ce7c089fc130769d5e206ee282b8582f2eb262e993b7ffc54c684693a
3
- size 8405159
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3e90eaa19d1496395514c94bf19b3b28caf7da2b314d765536b2e374f2ceb11e
3
+ size 1201632
samples/something-about-you-marilyn-ford/drums.mp3 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c2e6d121b06cd005c2b895a2f3762add95f3f2918fc4b969b39e737460e11c1f
3
- size 8405159
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:403e55faf8b2e4edf7b188c1d84de5075700b434eb07e5681160f24393dcb89a
3
+ size 1201632
samples/something-about-you-marilyn-ford/other.mp3 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2ae5fa3417e80043422aaf3d77705a2b34feda438bf1cf63962c647f1511474e
3
- size 8405159
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f9c075e3d6d1cd114c68bf45936a679acde56432557d996cc3984ddd6dd29db
3
+ size 1201632
samples/something-about-you-marilyn-ford/vocals.mp3 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:13d23712ba08f48035b067f221592be686ca6cca258ff0921483b6de5d96cef2
3
- size 8405159
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3cbff0465525dbc1cf1ea9c01c57a5f63c76c6a1b53ea6db84fadee67bbc1e6d
3
+ size 1201632