Spaces:
Running
Running
Fabio Grasso
commited on
Commit
·
871cdce
1
Parent(s):
8001894
feat: add examples and sidebar
Browse files- .gitattributes +1 -0
- app/examples.py +58 -0
- app/main.py +8 -1
- app/sidebar.py +15 -0
- samples/indie-rock.mp3 +3 -0
- samples/indie-rock/bass.mp3 +3 -0
- samples/indie-rock/drums.mp3 +3 -0
- samples/indie-rock/other.mp3 +3 -0
- samples/indie-rock/vocals.mp3 +3 -0
- samples/push-coma-media.mp3 +3 -0
- samples/push-coma-media/bass.mp3 +3 -0
- samples/push-coma-media/drums.mp3 +3 -0
- samples/push-coma-media/other.mp3 +3 -0
- samples/push-coma-media/vocals.mp3 +3 -0
- samples/something-about-you-marilyn-ford.mp3 +3 -0
- samples/something-about-you-marilyn-ford/bass.mp3 +3 -0
- samples/something-about-you-marilyn-ford/drums.mp3 +3 -0
- samples/something-about-you-marilyn-ford/other.mp3 +3 -0
- samples/something-about-you-marilyn-ford/vocals.mp3 +3 -0
.gitattributes
CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
app/examples.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
from app.helpers import load_audio_segment, plot_audio
|
4 |
+
|
5 |
+
def _load_example(name: str):
|
6 |
+
st.markdown("<center><h3> Original </h3></center>", unsafe_allow_html=True)
|
7 |
+
|
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()
|
15 |
+
st.audio(audio_bytes)
|
16 |
+
|
17 |
+
for file in ["vocals.mp3", "drums.mp3", "bass.mp3", "other.mp3"]:
|
18 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
19 |
+
label = file.split(".")[0].capitalize()
|
20 |
+
label = {
|
21 |
+
"Drums": "🥁",
|
22 |
+
"Bass": "🎸",
|
23 |
+
"Other": "🎹",
|
24 |
+
"Vocals": "🎤",
|
25 |
+
}.get(label) + " " + label
|
26 |
+
st.markdown("<center><h3>" + label + "</h3></center>", unsafe_allow_html=True)
|
27 |
+
|
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()
|
35 |
+
st.audio(audio_bytes)
|
36 |
+
|
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")
|
55 |
+
link = "https://pixabay.com/music/rnb-something-about-you-marilyn-ford-135781/"
|
56 |
+
st.markdown(
|
57 |
+
f"""Music by <a href="{link}">Marilyn Ford</a> from <a href="{link}">Pixabay</a>""",
|
58 |
+
unsafe_allow_html=True)
|
app/main.py
CHANGED
@@ -4,10 +4,12 @@ from pathlib import Path
|
|
4 |
|
5 |
import requests
|
6 |
import streamlit as st
|
|
|
7 |
|
8 |
from demucs_runner import separator
|
9 |
from lib.st_custom_components import st_audiorec
|
10 |
from helpers import load_audio_segment, plot_audio
|
|
|
11 |
|
12 |
logging.basicConfig(
|
13 |
format="%(asctime)s %(levelname)-8s %(message)s",
|
@@ -51,6 +53,8 @@ def url_is_valid(url):
|
|
51 |
|
52 |
def run():
|
53 |
st.markdown("<h1><center>🎶 Music Source Splitter</center></h1>", unsafe_allow_html=True)
|
|
|
|
|
54 |
st.markdown("""
|
55 |
<style>
|
56 |
.st-af {
|
@@ -145,4 +149,7 @@ def run():
|
|
145 |
st.audio(audio_bytes)
|
146 |
|
147 |
if __name__ == "__main__":
|
148 |
-
run()
|
|
|
|
|
|
|
|
4 |
|
5 |
import requests
|
6 |
import streamlit as st
|
7 |
+
from app.examples import show_examples
|
8 |
|
9 |
from demucs_runner import separator
|
10 |
from lib.st_custom_components import st_audiorec
|
11 |
from helpers import load_audio_segment, plot_audio
|
12 |
+
from sidebar import text as text_side
|
13 |
|
14 |
logging.basicConfig(
|
15 |
format="%(asctime)s %(levelname)-8s %(message)s",
|
|
|
53 |
|
54 |
def run():
|
55 |
st.markdown("<h1><center>🎶 Music Source Splitter</center></h1>", unsafe_allow_html=True)
|
56 |
+
st.markdown("<center><i>Hight Quality Audio Source Separation</i></center>", unsafe_allow_html=True)
|
57 |
+
st.sidebar.markdown(text_side, unsafe_allow_html=True)
|
58 |
st.markdown("""
|
59 |
<style>
|
60 |
.st-af {
|
|
|
149 |
st.audio(audio_bytes)
|
150 |
|
151 |
if __name__ == "__main__":
|
152 |
+
run()
|
153 |
+
st.markdown("<br><br>", unsafe_allow_html=True)
|
154 |
+
with st.expander("Show examples", expanded=False):
|
155 |
+
show_examples()
|
app/sidebar.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
text = """
|
2 |
+
<b>🎶 Music Source Splitter</b> is a web app that allows you to separate the vocals and the instrumental of a song.
|
3 |
+
<hr>
|
4 |
+
<h3>How does it work?</h3>
|
5 |
+
The app uses a pretrained model called Hybrid Spectrogram and Waveform Source Separation from <a href="https://github.com/facebookresearch/demucs">facebook/htdemucs</a>.
|
6 |
+
<br><br>
|
7 |
+
<h3>Where can I find the code?</h3>
|
8 |
+
The code for this app is available both on <a href="https://github.com/fabiogra/st-music-splitter">GitHub</a> and <a href="https://huggingface.co/spaces/fabiogra/st-music-splitter/tree/main">HuggingFace</a>.
|
9 |
+
<br><br>
|
10 |
+
<h3>Contact me</h3>
|
11 |
+
Contact me on <a href="https://twitter.com/grsFabio">Twitter</a> or on <a href="https://www.linkedin.com/in/fabio-grasso/">LinkedIn</a> if you have any questions or feedback.
|
12 |
+
|
13 |
+
![GitHub stars](https://img.shields.io/github/stars/fabiogra/st-music-splitter?style=social)
|
14 |
+
[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/fabiogra/st-music-splitter/tree/main)
|
15 |
+
"""
|
samples/indie-rock.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:775c80bbf15e53083191d62ca6f9350a383ec48a8d09878372875cbc3b68423e
|
3 |
+
size 4578324
|
samples/indie-rock/bass.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:100ef5359158ae7810e2c6f20d7d83d0b276b528c8888cd956f61410faf34c9a
|
3 |
+
size 5723951
|
samples/indie-rock/drums.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3c873bc4958cb02f8e338c2958d83c36525f1d5a668c48dd9200d8822a37a6e7
|
3 |
+
size 5723951
|
samples/indie-rock/other.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d06239063e7e14b70a8b794635ddbe5d30b5fea86c317e885c680bb7399b012b
|
3 |
+
size 5723951
|
samples/indie-rock/vocals.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a9b0f4ce89506fb7001a5f676ac90f930a46c179779251284129202a39f8903f
|
3 |
+
size 5723951
|
samples/push-coma-media.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:92058637b42733b61b5c2f6c9fa3367919eb3a43cea5415893a56f39927ac528
|
3 |
+
size 3354540
|
samples/push-coma-media/bass.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b235327107bae1aff207b649da4a9a8679dee8cb25aae66655529dbd5568cc62
|
3 |
+
size 4194220
|
samples/push-coma-media/drums.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2f1dec9e42305f0db9fbfe6b2a409bd3cf158b7402680571ad72fd746b9c5bb6
|
3 |
+
size 4194220
|
samples/push-coma-media/other.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:31d6b52b48a873126d7e8bb8cb5809d94f7168e7bfddd1afd86abddc50cca1fb
|
3 |
+
size 4194220
|
samples/push-coma-media/vocals.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:94e7fb8f4330b0eea772fd8cff766d4dc986163ccda4dab0b5837fc6ee5851c8
|
3 |
+
size 4194220
|
samples/something-about-you-marilyn-ford.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8d8072ba713f89116c703e24272ecbc4435f2309ab6637f4d32175e75257b530
|
3 |
+
size 6723291
|
samples/something-about-you-marilyn-ford/bass.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:068a054ce7c089fc130769d5e206ee282b8582f2eb262e993b7ffc54c684693a
|
3 |
+
size 8405159
|
samples/something-about-you-marilyn-ford/drums.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c2e6d121b06cd005c2b895a2f3762add95f3f2918fc4b969b39e737460e11c1f
|
3 |
+
size 8405159
|
samples/something-about-you-marilyn-ford/other.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2ae5fa3417e80043422aaf3d77705a2b34feda438bf1cf63962c647f1511474e
|
3 |
+
size 8405159
|
samples/something-about-you-marilyn-ford/vocals.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:13d23712ba08f48035b067f221592be686ca6cca258ff0921483b6de5d96cef2
|
3 |
+
size 8405159
|