Taejun Kim commited on
Commit
3f9fabf
1 Parent(s): 269c399

Add descriptions

Browse files
Files changed (2) hide show
  1. app.py +29 -10
  2. style.css +13 -0
app.py CHANGED
@@ -1,21 +1,37 @@
1
  import gradio as gr
 
2
  import allin1
3
 
4
  from pathlib import Path
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  DESCRIPTION = """
7
- # All-In-One Music Structure Analyzer
8
 
9
  This Space demonstrates [All-In-One Music Structure Analyzer](https://github.com/mir-aidj/all-in-one),
10
- a tool that predicts the BPM, beats, downbeats, segment boundaries, and functional segment labels from audio files.
 
 
 
 
 
11
 
12
- For more information, please visit:
13
- - Python package: [`allin1`](https://github.com/mir-aidj/all-in-one)
14
- - Structure visualizer: [Music Dissector](https://taejun.kim/music-dissector/)
15
- - Paper: [All-In-One Metrical And Functional Structure Analysis With Neighborhood Attentions on Demixed Audio
16
- ](https://arxiv.org/abs/2307.16425)
17
  """
18
 
 
 
19
 
20
  def analyze(path):
21
  path = Path(path)
@@ -31,8 +47,10 @@ def analyze(path):
31
  return result.bpm, fig, sonif_path
32
 
33
 
34
- with gr.Blocks() as demo:
 
35
  gr.Markdown(DESCRIPTION)
 
36
  input_audio_path = gr.Audio(
37
  label='Input',
38
  source='upload',
@@ -56,7 +74,7 @@ with gr.Blocks() as demo:
56
  inputs=input_audio_path,
57
  outputs=[output_bpm, output_viz, output_sonif],
58
  fn=analyze,
59
- cache_examples=True,
60
  )
61
  button.click(
62
  fn=analyze,
@@ -65,4 +83,5 @@ with gr.Blocks() as demo:
65
  api_name='analyze',
66
  )
67
 
68
- demo.queue().launch()
 
 
1
  import gradio as gr
2
+ import os
3
  import allin1
4
 
5
  from pathlib import Path
6
 
7
+ HEADER = """
8
+ <header>
9
+ <h1>
10
+ All-In-One Music Structure Analyzer 🔮
11
+ </h1>
12
+ <p>
13
+ <a href="https://github.com/mir-aidj/all-in-one">[Python Package]</a>
14
+ <a href="https://arxiv.org/abs/2307.16425">[Paper]</a>
15
+ <a href="https://taejun.kim/music-dissector/">[Visual Demo]</a>
16
+ </p>
17
+ </header>
18
+ """
19
+
20
  DESCRIPTION = """
 
21
 
22
  This Space demonstrates [All-In-One Music Structure Analyzer](https://github.com/mir-aidj/all-in-one),
23
+ a tool that predicts:
24
+ - BPM
25
+ - Beats
26
+ - Downbeats
27
+ - Functional segment boundaries
28
+ - Functional segment labels
29
 
30
+ For more information, please visit the links above ✨🧸
 
 
 
 
31
  """
32
 
33
+ CACHE_EXAMPLES = os.getenv('CACHE_EXAMPLES', '1') == '1'
34
+
35
 
36
  def analyze(path):
37
  path = Path(path)
 
47
  return result.bpm, fig, sonif_path
48
 
49
 
50
+ with gr.Blocks(css='style.css') as demo:
51
+ gr.HTML(HEADER)
52
  gr.Markdown(DESCRIPTION)
53
+
54
  input_audio_path = gr.Audio(
55
  label='Input',
56
  source='upload',
 
74
  inputs=input_audio_path,
75
  outputs=[output_bpm, output_viz, output_sonif],
76
  fn=analyze,
77
+ cache_examples=CACHE_EXAMPLES,
78
  )
79
  button.click(
80
  fn=analyze,
 
83
  api_name='analyze',
84
  )
85
 
86
+ if __name__ == '__main__':
87
+ demo.launch()
style.css ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ header {
2
+ text-align: center;
3
+ }
4
+
5
+ ul {
6
+ padding-left: 1rem !important;
7
+ }
8
+
9
+ #component-0 {
10
+ max-width: 900px;
11
+ margin: auto;
12
+ padding-top: 1.5rem;
13
+ }