csukuangfj commited on
Commit
9def7a4
1 Parent(s): f011d50

small fixes

Browse files
Files changed (3) hide show
  1. app.py +12 -3
  2. separate.py +2 -4
  3. yesterday-once-more-Carpenters.mp3 +0 -3
app.py CHANGED
@@ -20,6 +20,7 @@
20
  # https://gradio.app/docs/#dropdown
21
 
22
  import logging
 
23
  import tempfile
24
  import time
25
  import urllib.request
@@ -29,7 +30,15 @@ import gradio as gr
29
  import torch
30
  from pydub import AudioSegment
31
 
32
- from separate import load_audio, load_model, separate
 
 
 
 
 
 
 
 
33
 
34
 
35
  def build_html_output(s: str, style: str = "result_item_success"):
@@ -172,7 +181,7 @@ with demo:
172
  uploaded_accompaniment = gr.Audio(label="accompaniment")
173
 
174
  gr.Examples(
175
- examples=["./yesterday-once-more-Carpenters.wav"],
176
  inputs=[uploaded_file],
177
  outputs=[uploaded_vocals, uploaded_accompaniment, uploaded_html_info],
178
  fn=process_uploaded_file,
@@ -193,7 +202,7 @@ with demo:
193
  recorded_accompaniment = gr.Audio(label="accompaniment")
194
 
195
  gr.Examples(
196
- examples=["./yesterday-once-more-Carpenters.wav"],
197
  inputs=[microphone],
198
  outputs=[recorded_vocals, recorded_accompaniment, recorded_html_info],
199
  fn=process_microphone,
 
20
  # https://gradio.app/docs/#dropdown
21
 
22
  import logging
23
+ import shutil
24
  import tempfile
25
  import time
26
  import urllib.request
 
30
  import torch
31
  from pydub import AudioSegment
32
 
33
+ from separate import get_file, load_audio, load_model, separate
34
+
35
+ filename = get_file(
36
+ "csukuangfj/spleeter-torch",
37
+ " yesterday-once-more-Carpenters.mp3",
38
+ subfolder="test_wavs",
39
+ )
40
+
41
+ shutil.copyfile(filename, "./yesterday-once-more-Carpenters.mp3")
42
 
43
 
44
  def build_html_output(s: str, style: str = "result_item_success"):
 
181
  uploaded_accompaniment = gr.Audio(label="accompaniment")
182
 
183
  gr.Examples(
184
+ examples=["./yesterday-once-more-Carpenters.mp3"],
185
  inputs=[uploaded_file],
186
  outputs=[uploaded_vocals, uploaded_accompaniment, uploaded_html_info],
187
  fn=process_uploaded_file,
 
202
  recorded_accompaniment = gr.Audio(label="accompaniment")
203
 
204
  gr.Examples(
205
+ examples=["./yesterday-once-more-Carpenters.mp3"],
206
  inputs=[microphone],
207
  outputs=[recorded_vocals, recorded_accompaniment, recorded_html_info],
208
  fn=process_microphone,
separate.py CHANGED
@@ -133,7 +133,7 @@ def separate(
133
 
134
 
135
  @lru_cache(maxsize=10)
136
- def get_nn_model_filename(
137
  repo_id: str,
138
  filename: str,
139
  subfolder: str = "2stems",
@@ -150,9 +150,7 @@ def get_nn_model_filename(
150
  def load_model(name: str):
151
  net = UNet()
152
  net.eval()
153
- filename = get_nn_model_filename(
154
- "csukuangfj/spleeter-torch", name, subfolder="2stems"
155
- )
156
 
157
  state_dict = torch.load(filename, map_location="cpu")
158
  net.load_state_dict(state_dict)
 
133
 
134
 
135
  @lru_cache(maxsize=10)
136
+ def get_file(
137
  repo_id: str,
138
  filename: str,
139
  subfolder: str = "2stems",
 
150
  def load_model(name: str):
151
  net = UNet()
152
  net.eval()
153
+ filename = get_file("csukuangfj/spleeter-torch", name, subfolder="2stems")
 
 
154
 
155
  state_dict = torch.load(filename, map_location="cpu")
156
  net.load_state_dict(state_dict)
yesterday-once-more-Carpenters.mp3 DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d9831b4b08f24beb3b06ee5b058e9fee6f13982b2325b828c0ff6e7cb8b6050d
3
- size 3938651