Spaces:
Sleeping
Sleeping
Taejun Kim
commited on
Commit
•
4bb84bd
1
Parent(s):
cb80448
Add examples
Browse files- .gitattributes +1 -0
- .gitignore +4 -0
- app.py +26 -22
- assets/NewJeans - Super Shy.mp3 +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
demix/
|
2 |
+
sonif/
|
3 |
+
spec/
|
4 |
+
flagged/
|
app.py
CHANGED
@@ -3,34 +3,29 @@ import allin1
|
|
3 |
|
4 |
from pathlib import Path
|
5 |
|
|
|
|
|
6 |
|
7 |
-
|
|
|
|
|
|
|
|
|
8 |
path = Path(path)
|
9 |
result = allin1.analyze(
|
10 |
path,
|
|
|
11 |
keep_byproducts=True, # TODO: remove this
|
12 |
)
|
13 |
fig = allin1.visualize(result)
|
14 |
allin1.sonify(result, out_dir='./sonif')
|
|
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
def list_files(startpath):
|
19 |
-
for root, dirs, files in os.walk(startpath):
|
20 |
-
level = root.replace(startpath, '').count(os.sep)
|
21 |
-
indent = ' ' * 4 * level
|
22 |
-
print('{}{}/'.format(indent, os.path.basename(root)))
|
23 |
-
subindent = ' ' * 4 * (level + 1)
|
24 |
-
for f in files:
|
25 |
-
print('{}{}'.format(subindent, f))
|
26 |
-
|
27 |
-
startpath = '.' # start from the current directory
|
28 |
-
list_files(startpath)
|
29 |
-
|
30 |
-
return fig, Path(f'./sonif/{path.stem}.sonif{path.suffix}').resolve().as_posix()
|
31 |
|
32 |
|
33 |
with gr.Blocks() as demo:
|
|
|
34 |
input_audio_path = gr.Audio(
|
35 |
label='Input',
|
36 |
source='upload',
|
@@ -38,6 +33,8 @@ with gr.Blocks() as demo:
|
|
38 |
format='mp3',
|
39 |
show_download_button=False,
|
40 |
)
|
|
|
|
|
41 |
output_viz = gr.Plot(label='Visualization')
|
42 |
output_sonif = gr.Audio(
|
43 |
label='Sonification',
|
@@ -45,13 +42,20 @@ with gr.Blocks() as demo:
|
|
45 |
format='mp3',
|
46 |
show_download_button=False,
|
47 |
)
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
inputs=input_audio_path,
|
52 |
-
outputs=[output_viz, output_sonif],
|
53 |
api_name='analyze',
|
54 |
)
|
55 |
|
56 |
-
|
57 |
-
demo.queue().launch()
|
|
|
3 |
|
4 |
from pathlib import Path
|
5 |
|
6 |
+
DESCRIPTION = """
|
7 |
+
# All-In-One Music Structure Analyzer
|
8 |
|
9 |
+
This Space demonstrates Python package [allin1](
|
10 |
+
"""
|
11 |
+
|
12 |
+
|
13 |
+
def analyze(path):
|
14 |
path = Path(path)
|
15 |
result = allin1.analyze(
|
16 |
path,
|
17 |
+
multiprocess=False,
|
18 |
keep_byproducts=True, # TODO: remove this
|
19 |
)
|
20 |
fig = allin1.visualize(result)
|
21 |
allin1.sonify(result, out_dir='./sonif')
|
22 |
+
sonif_path = Path(f'./sonif/{path.stem}.sonif{path.suffix}').resolve().as_posix()
|
23 |
|
24 |
+
return result.bpm, fig, sonif_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
|
27 |
with gr.Blocks() as demo:
|
28 |
+
gr.Markdown(DESCRIPTION)
|
29 |
input_audio_path = gr.Audio(
|
30 |
label='Input',
|
31 |
source='upload',
|
|
|
33 |
format='mp3',
|
34 |
show_download_button=False,
|
35 |
)
|
36 |
+
button = gr.Button('Analyze', variant='primary')
|
37 |
+
output_bpm = gr.Textbox(label='BPM')
|
38 |
output_viz = gr.Plot(label='Visualization')
|
39 |
output_sonif = gr.Audio(
|
40 |
label='Sonification',
|
|
|
42 |
format='mp3',
|
43 |
show_download_button=False,
|
44 |
)
|
45 |
+
gr.Examples(
|
46 |
+
examples=[
|
47 |
+
'./assets/NewJeans - Super Shy.mp3',
|
48 |
+
],
|
49 |
+
inputs=input_audio_path,
|
50 |
+
outputs=[output_bpm, output_viz, output_sonif],
|
51 |
+
fn=analyze,
|
52 |
+
cache_examples=True,
|
53 |
+
)
|
54 |
+
button.click(
|
55 |
+
fn=analyze,
|
56 |
inputs=input_audio_path,
|
57 |
+
outputs=[output_bpm, output_viz, output_sonif],
|
58 |
api_name='analyze',
|
59 |
)
|
60 |
|
61 |
+
demo.queue().launch()
|
|
assets/NewJeans - Super Shy.mp3
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c5b6e0015079814088a34633db74aa1e6e9435fdaa8a4633d5b730b5165dad36
|
3 |
+
size 6398696
|