Tachyeon commited on
Commit
70b2d07
·
verified ·
1 Parent(s): 8a365bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +150 -85
app.py CHANGED
@@ -6,7 +6,7 @@ import soundfile as sf
6
  import numpy as np
7
  from huggingface_hub import hf_hub_download
8
 
9
- # ================= MODEL (UNCHANGED) =================
10
  try:
11
  from bs_roformer import BSRoformer
12
  from attend import Attend
@@ -76,7 +76,7 @@ def separate_audio(path):
76
  files.append(f)
77
  return files
78
 
79
- # ================= UI =================
80
  css = """
81
  @import url('https://fonts.googleapis.com/css2?family=Anton&family=Poppins:wght@400;500;600&display=swap');
82
 
@@ -86,141 +86,206 @@ css = """
86
  --ink:#f3ece6;
87
  --muted:#b6aeb0;
88
  --accent:#ff6f9f;
89
- --panel:rgba(255,255,255,0.035);
 
 
90
  }
91
 
92
- html,body,.gradio-container{
93
- height:100%;
94
- margin:0;
95
- background:linear-gradient(180deg,var(--bg1),var(--bg2))!important;
96
- font-family:Poppins,sans-serif;
97
- color:var(--ink);
98
- overflow:hidden!important;
 
 
99
  }
100
 
101
- .app{
102
- max-width:1100px;
103
- margin:0 auto;
104
- padding:48px 40px;
105
- height:100%;
106
- display:grid;
107
- grid-template-rows:auto 1fr;
108
- gap:44px;
 
109
  }
110
 
111
- .header{
 
112
  display:flex;
113
  flex-direction:column;
114
  gap:6px;
115
  }
116
-
117
- .logo{
118
- font-family:Anton,sans-serif;
119
- font-size:44px;
120
  letter-spacing:1px;
121
  }
122
-
123
- .tagline{
124
  font-size:14px;
125
  color:var(--accent);
126
- opacity:.85;
 
127
  }
128
 
129
- .main{
 
130
  display:grid;
131
- grid-template-columns:1.1fr .9fr;
132
- gap:48px;
133
- align-items:start;
134
  }
135
 
136
- .left h3{
137
- font-weight:500;
138
- margin:0;
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
 
141
- .left p{
142
- color:var(--muted);
143
- font-size:13px;
144
- margin:6px 0 18px;
145
  }
146
 
147
- .gradio-audio label{
148
- display:none!important;
 
 
 
 
 
 
 
 
 
 
149
  }
150
 
151
- .gradio-audio{
152
- background:var(--panel)!important;
153
- border-radius:14px!important;
 
 
 
154
  }
155
 
156
- audio{
157
- opacity:.85;
158
- background:none!important;
 
 
 
 
 
 
 
 
 
159
  }
160
 
161
- .button-primary{
162
- margin-top:16px;
163
- height:46px;
164
- font-weight:600!important;
165
- font-size:14px!important;
166
- background:linear-gradient(90deg,#ff6f9f,#ffbf7a)!important;
167
- color:#14080d!important;
168
- border-radius:12px!important;
169
  }
170
 
171
- .stems{
172
- display:grid;
173
- grid-template-columns:1fr 1fr;
174
- gap:26px;
175
- margin-top:2px;
176
  }
177
 
178
- .stem{
 
 
 
 
 
179
  display:flex;
180
- flex-direction:column;
181
- gap:6px;
182
  }
183
 
184
- .stem span{
185
- font-size:13px;
186
- font-weight:500;
187
- color:var(--accent);
188
- opacity:.9;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  }
190
  """
191
 
192
  with gr.Blocks() as demo:
193
  with gr.Column(elem_classes="app"):
194
 
195
- with gr.Column(elem_classes="header"):
 
196
  gr.HTML('<div class="logo">SWARA STUDIO</div>')
 
197
  gr.HTML('<div class="tagline">Separating Music Into Its elements</div>')
198
 
 
199
  with gr.Row(elem_classes="main"):
 
200
  with gr.Column(elem_classes="left"):
201
  gr.HTML("""
202
  <h3>Select a track</h3>
203
  <p>We’ll break it down into individual parts</p>
204
  """)
205
- inp = gr.Audio(type="filepath")
206
- btn = gr.Button("Separate", elem_classes="button-primary")
207
 
 
208
  with gr.Column():
209
  with gr.Row(elem_classes="stems"):
210
- with gr.Column(elem_classes="stem"):
211
- gr.HTML("<span>Vocals</span>")
212
- o1 = gr.Audio(interactive=False)
213
- with gr.Column(elem_classes="stem"):
214
- gr.HTML("<span>Drums</span>")
215
- o2 = gr.Audio(interactive=False)
216
- with gr.Column(elem_classes="stem"):
217
- gr.HTML("<span>Bass</span>")
218
- o3 = gr.Audio(interactive=False)
219
- with gr.Column(elem_classes="stem"):
220
- gr.HTML("<span>Other</span>")
221
- o4 = gr.Audio(interactive=False)
222
-
223
- btn.click(separate_audio, inp, [o1,o2,o3,o4])
224
-
225
- if __name__=="__main__":
 
226
  demo.launch(css=css, theme=gr.themes.Base())
 
6
  import numpy as np
7
  from huggingface_hub import hf_hub_download
8
 
9
+ # ================= MODEL (unchanged) =================
10
  try:
11
  from bs_roformer import BSRoformer
12
  from attend import Attend
 
76
  files.append(f)
77
  return files
78
 
79
+ # ================= UI CSS + layout (polished) =================
80
  css = """
81
  @import url('https://fonts.googleapis.com/css2?family=Anton&family=Poppins:wght@400;500;600&display=swap');
82
 
 
86
  --ink:#f3ece6;
87
  --muted:#b6aeb0;
88
  --accent:#ff6f9f;
89
+ --panel: rgba(255,255,255,0.03);
90
+ --panel-2: rgba(255,255,255,0.02);
91
+ --radius: 12px;
92
  }
93
 
94
+ /* page reset */
95
+ html, body, .gradio-container {
96
+ height: 100%;
97
+ margin: 0;
98
+ padding: 0;
99
+ background: linear-gradient(180deg, var(--bg1), var(--bg2)) !important;
100
+ color: var(--ink);
101
+ font-family: Poppins, sans-serif;
102
+ overflow: auto;
103
  }
104
 
105
+ /* wrapper */
106
+ .app {
107
+ max-width: 1160px;
108
+ margin: 0 auto;
109
+ padding: 48px 40px;
110
+ box-sizing: border-box;
111
+ display: grid;
112
+ grid-template-rows: auto 1fr;
113
+ gap: 36px;
114
  }
115
 
116
+ /* logo + tagline (left-anchored brand lockup) */
117
+ .brand {
118
  display:flex;
119
  flex-direction:column;
120
  gap:6px;
121
  }
122
+ .logo {
123
+ font-family: Anton, sans-serif;
124
+ font-size:46px;
 
125
  letter-spacing:1px;
126
  }
127
+ .tagline {
 
128
  font-size:14px;
129
  color:var(--accent);
130
+ opacity:0.9;
131
+ text-transform: none; /* keep exact caps as user wanted */
132
  }
133
 
134
+ /* main grid: left upload (dominant) and right stems column */
135
+ .main {
136
  display:grid;
137
+ grid-template-columns: 1fr 420px; /* fixed right column to keep alignment predictable */
138
+ gap: 48px;
139
+ align-items: start; /* ensure top baseline alignment */
140
  }
141
 
142
+ /* left column content */
143
+ .left h3 { margin: 0; font-size:18px; font-weight:600; }
144
+ .left p { margin:6px 0 18px; color:var(--muted); font-size:13px; }
145
+
146
+ /* style the Gradio audio drop area so it's visually lighter and slightly shorter */
147
+ .left .gradio-audio {
148
+ background: var(--panel) !important;
149
+ border-radius: var(--radius) !important;
150
+ border: 1px solid rgba(255,255,255,0.04) !important;
151
+ padding: 12px !important;
152
+ box-sizing: border-box;
153
+ min-height: 260px; /* reduced height so stems line up better */
154
+ display:flex;
155
+ align-items:center;
156
+ justify-content:center;
157
  }
158
 
159
+ /* tone-down the upload inner texts to make them less dominant */
160
+ .left .gradio-audio .dropzone, .left .gradio-audio .component, .left .gradio-audio .file {
161
+ color: var(--muted) !important;
 
162
  }
163
 
164
+ /* Make the CTA authoritative but balanced */
165
+ .button-primary {
166
+ margin-top: 18px;
167
+ height:46px;
168
+ width:100%;
169
+ font-size:15px !important;
170
+ font-weight:600 !important;
171
+ background: linear-gradient(90deg,#ff6f9f,#ffbf7a) !important;
172
+ color: #14080d !important;
173
+ border-radius: 10px !important;
174
+ border: none !important;
175
+ box-shadow: 0 8px 30px rgba(0,0,0,0.25);
176
  }
177
 
178
+ /* RIGHT COLUMN (stems) - keep fixed width, grid with 2 columns */
179
+ .stems {
180
+ display: grid;
181
+ grid-template-columns: 1fr 1fr;
182
+ gap: 22px;
183
+ align-items: start;
184
  }
185
 
186
+ /* each stem slot now reads like a subdued surface */
187
+ .stem-surface {
188
+ background: var(--panel-2);
189
+ border-radius: 14px;
190
+ padding: 12px;
191
+ border: 1px solid rgba(255,255,255,0.03);
192
+ box-sizing: border-box;
193
+ min-height: 140px; /* consistent stem surface height */
194
+ display: flex;
195
+ flex-direction: column;
196
+ gap: 10px;
197
+ justify-content: center;
198
  }
199
 
200
+ /* stem label: same system rhythm as body (no competing font) */
201
+ .stem-label {
202
+ font-size:13px;
203
+ font-weight:500;
204
+ color: var(--accent);
205
+ margin-left: 4px;
 
 
206
  }
207
 
208
+ /* neutralize Gradio's internal "Audio" label visually so it doesn't fight the stem label */
209
+ .stem-surface .gradio-audio label {
210
+ display:none !important;
 
 
211
  }
212
 
213
+ /* smaller inner audio player to avoid odd spacing */
214
+ .stem-surface .gradio-audio {
215
+ background: transparent !important;
216
+ border: 0 !important;
217
+ padding: 0 !important;
218
+ min-height: 88px !important;
219
  display:flex;
220
+ align-items:center;
221
+ justify-content:center;
222
  }
223
 
224
+ /* ensure the internal audio element doesn't expand */
225
+ .stem-surface audio {
226
+ width: 92%;
227
+ max-height: 36px;
228
+ opacity: 0.95;
229
+ }
230
+
231
+ /* remove any extra left margin coming from gradio wrapper */
232
+ .gradio-container .wrap { margin: 0; padding: 0; }
233
+
234
+ /* footer info (small) */
235
+ .footer {
236
+ margin-top: 28px;
237
+ text-align: center;
238
+ color: var(--muted);
239
+ font-size: 12px;
240
+ opacity: 0.95;
241
+ }
242
+
243
+ /* small responsive fallback */
244
+ @media (max-width: 980px) {
245
+ .main { grid-template-columns: 1fr; }
246
+ .stems { grid-template-columns: 1fr 1fr; gap:16px; }
247
+ .app { padding: 28px 20px; }
248
  }
249
  """
250
 
251
  with gr.Blocks() as demo:
252
  with gr.Column(elem_classes="app"):
253
 
254
+ # Brand lockup (left-anchored)
255
+ with gr.Row(elem_classes="brand"):
256
  gr.HTML('<div class="logo">SWARA STUDIO</div>')
257
+ # exact user-caps as requested
258
  gr.HTML('<div class="tagline">Separating Music Into Its elements</div>')
259
 
260
+ # Main content (left upload, right stems). Top baselines match now.
261
  with gr.Row(elem_classes="main"):
262
+ # LEFT: upload + CTA
263
  with gr.Column(elem_classes="left"):
264
  gr.HTML("""
265
  <h3>Select a track</h3>
266
  <p>We’ll break it down into individual parts</p>
267
  """)
268
+ input_audio = gr.Audio(type="filepath")
269
+ run_btn = gr.Button("Separate", elem_classes="button-primary")
270
 
271
+ # RIGHT: stems grid (fixed width column)
272
  with gr.Column():
273
  with gr.Row(elem_classes="stems"):
274
+ with gr.Column(elem_classes="stem-surface"):
275
+ gr.HTML('<div class="stem-label">Vocals</div>')
276
+ out_vocals = gr.Audio(interactive=False)
277
+ with gr.Column(elem_classes="stem-surface"):
278
+ gr.HTML('<div class="stem-label">Drums</div>')
279
+ out_drums = gr.Audio(interactive=False)
280
+ with gr.Column(elem_classes="stem-surface"):
281
+ gr.HTML('<div class="stem-label">Bass</div>')
282
+ out_bass = gr.Audio(interactive=False)
283
+ with gr.Column(elem_classes="stem-surface"):
284
+ gr.HTML('<div class="stem-label">Other</div>')
285
+ out_other = gr.Audio(interactive=False)
286
+
287
+ # wiring — unchanged logic
288
+ run_btn.click(separate_audio, input_audio, [out_vocals, out_drums, out_bass, out_other])
289
+
290
+ if __name__ == "__main__":
291
  demo.launch(css=css, theme=gr.themes.Base())