Taejun Kim commited on
Commit
6e76183
1 Parent(s): d955472

Improve the style

Browse files
Files changed (2) hide show
  1. app.py +37 -23
  2. style.css +0 -13
app.py CHANGED
@@ -5,7 +5,7 @@ import allin1
5
  from pathlib import Path
6
 
7
  HEADER = """
8
- <header>
9
  <h1>
10
  All-In-One Music Structure Analyzer 🔮
11
  </h1>
@@ -15,19 +15,29 @@ HEADER = """
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'
@@ -40,16 +50,18 @@ def analyze(path):
40
  multiprocess=False,
41
  keep_byproducts=True, # TODO: remove this
42
  )
 
43
  fig = allin1.visualize(result)
 
 
44
  allin1.sonify(result, out_dir='./sonif')
45
  sonif_path = Path(f'./sonif/{path.stem}.sonif{path.suffix}').resolve().as_posix()
46
 
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',
@@ -59,14 +71,16 @@ with gr.Blocks(css='style.css') as demo:
59
  show_download_button=False,
60
  )
61
  button = gr.Button('Analyze', variant='primary')
62
- output_bpm = gr.Textbox(label='BPM')
63
  output_viz = gr.Plot(label='Visualization')
64
- output_sonif = gr.Audio(
65
- label='Sonification',
66
- type='filepath',
67
- format='mp3',
68
- show_download_button=False,
69
- )
 
 
 
70
  gr.Examples(
71
  examples=[
72
  './assets/NewJeans - Super Shy.mp3',
 
5
  from pathlib import Path
6
 
7
  HEADER = """
8
+ <header style="text-align: center;">
9
  <h1>
10
  All-In-One Music Structure Analyzer 🔮
11
  </h1>
 
15
  <a href="https://taejun.kim/music-dissector/">[Visual Demo]</a>
16
  </p>
17
  </header>
18
+ <main
19
+ style="display: flex; justify-content: center;"
20
+ >
21
+ <div
22
+ style="display: inline-block;"
23
+ >
24
+ <p>
25
+ This Space demonstrates the music structure analyzer predicts:
26
+ <ul
27
+ style="padding-left: 1rem;"
28
+ >
29
+ <li>BPM</li>
30
+ <li>Beats</li>
31
+ <li>Downbeats</li>
32
+ <li>Functional segment boundaries</li>
33
+ <li>Functional segment labels (e.g. intro, verse, chorus, bridge, outro)</li>
34
+ </ul>
35
+ </p>
36
+ <p>
37
+ For more information, please visit the links above ✨🧸
38
+ </p>
39
+ </div>
40
+ </main>
41
  """
42
 
43
  CACHE_EXAMPLES = os.getenv('CACHE_EXAMPLES', '1') == '1'
 
50
  multiprocess=False,
51
  keep_byproducts=True, # TODO: remove this
52
  )
53
+
54
  fig = allin1.visualize(result)
55
+ fig.set_dpi(300)
56
+
57
  allin1.sonify(result, out_dir='./sonif')
58
  sonif_path = Path(f'./sonif/{path.stem}.sonif{path.suffix}').resolve().as_posix()
59
 
60
  return result.bpm, fig, sonif_path
61
 
62
 
63
+ with gr.Blocks() as demo:
64
  gr.HTML(HEADER)
 
65
 
66
  input_audio_path = gr.Audio(
67
  label='Input',
 
71
  show_download_button=False,
72
  )
73
  button = gr.Button('Analyze', variant='primary')
 
74
  output_viz = gr.Plot(label='Visualization')
75
+ with gr.Row():
76
+ output_bpm = gr.Textbox(label='BPM', scale=1)
77
+ output_sonif = gr.Audio(
78
+ label='Sonification',
79
+ type='filepath',
80
+ format='mp3',
81
+ show_download_button=False,
82
+ scale=9,
83
+ )
84
  gr.Examples(
85
  examples=[
86
  './assets/NewJeans - Super Shy.mp3',
style.css DELETED
@@ -1,13 +0,0 @@
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
- }