Ashhar commited on
Commit
5d68a5f
·
1 Parent(s): 857cbb4

first commit

Browse files
Files changed (4) hide show
  1. .gitignore +6 -0
  2. README.md +3 -30
  3. app.py +46 -20
  4. requirements.txt +6 -5
.gitignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ .env
2
+ .venv
3
+ __pycache__/
4
+ .gitattributes
5
+ gradio_cached_examples/
6
+ app_*.py
README.md CHANGED
@@ -1,38 +1,11 @@
1
  ---
2
- title: Demucs Music Source Separation (v4)
3
- emoji:
4
  colorFrom: red
5
  colorTo: purple
6
  sdk: gradio
7
  app_file: app.py
8
  pinned: true
9
- duplicated_from: Thafx/Demucs_v4_2s_HT
10
  ---
11
 
12
- # Configuration
13
-
14
- `title`: _string_
15
- Display title for the Space
16
-
17
- `emoji`: _string_
18
- Space emoji (emoji-only character allowed)
19
-
20
- `colorFrom`: _string_
21
- Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
22
-
23
- `colorTo`: _string_
24
- Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
25
-
26
- `sdk`: _string_
27
- Can be either `gradio` or `streamlit`
28
-
29
- `sdk_version` : _string_
30
- Only applicable for `streamlit` SDK.
31
- See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
32
-
33
- `app_file`: _string_
34
- Path to your main application file (which contains either `gradio` or `streamlit` Python code).
35
- Path is relative to the root of the repository.
36
-
37
- `pinned`: _boolean_
38
- Whether the Space stays on top of your list.
 
1
  ---
2
+ title: Music Source Separation
3
+ emoji: 🎶
4
  colorFrom: red
5
  colorTo: purple
6
  sdk: gradio
7
  app_file: app.py
8
  pinned: true
 
9
  ---
10
 
11
+ Duplicated from https://huggingface.co/spaces/abidlabs/music-separation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app.py CHANGED
@@ -1,21 +1,47 @@
1
- import os
2
  import gradio as gr
3
- from scipy.io.wavfile import write
4
-
5
-
6
- def inference(audio):
7
- os.makedirs("out", exist_ok=True)
8
- write('test.wav', audio[0], audio[1])
9
- os.system("python3 -m demucs.separate -n htdemucs --two-stems=vocals test.wav -o out")
10
- return "./out/htdemucs/test/vocals.wav","./out/htdemucs/test/no_vocals.wav"
11
-
12
- title = "Demucs Music Source Separation (v4)"
13
- article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1911.13254' target='_blank'>Music Source Separation in the Waveform Domain</a> | <a href='https://github.com/facebookresearch/demucs' target='_blank'>Github Repo</a> | <a href='https://www.thafx.com' target='_blank'>//THAFX</a></p>"
14
-
15
- gr.Interface(
16
- inference,
17
- gr.Audio(type="numpy", label="Input"),
18
- [gr.Audio(type="filepath", label="Vocals"),gr.Audio(type="filepath", label="No Vocals / Instrumental")],
19
- title=title,
20
- article=article,
21
- ).launch(enable_queue=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import datetime as DT
3
+ import pytz
4
+ from gradio_client import Client
5
+
6
+ ipAddress = None
7
+
8
+
9
+ def __nowInIST():
10
+ return DT.datetime.now(pytz.timezone("Asia/Kolkata"))
11
+
12
+
13
+ def __attachIp(request: gr.Request):
14
+ global ipAddress
15
+ x_forwarded_for = request.headers.get('x-forwarded-for')
16
+ if x_forwarded_for:
17
+ ipAddress = x_forwarded_for
18
+
19
+
20
+ def pprint(log: str):
21
+ now = __nowInIST()
22
+ now = now.strftime("%Y-%m-%d %H:%M:%S")
23
+ print(f"[{now}] [{ipAddress}] {log}")
24
+
25
+
26
+ def predict(audio):
27
+ client = Client("https://abidlabs-music-separation.hf.space/")
28
+ result = client.predict(
29
+ audio,
30
+ api_name="/predict"
31
+ )
32
+ return result
33
+
34
+
35
+ with gr.Interface(
36
+ predict,
37
+ inputs=gr.Audio(type="filepath", label="Input"),
38
+ outputs=[
39
+ gr.Audio(type="filepath", label="Vocals"),
40
+ gr.Audio(type="filepath", label="No Vocals / Instrumental")
41
+ ],
42
+ title="Split your song into vocals & music",
43
+ article="<p style='text-align: center'>Credits: <a href: 'https://huggingface.co/spaces/abidlabs/music-separation'>abidlabs/music-separation</a> </>",
44
+ ) as demo:
45
+ demo.load(__attachIp, None, None)
46
+
47
+ demo.launch(debug=True)
requirements.txt CHANGED
@@ -1,7 +1,8 @@
1
- git+https://github.com/facebookresearch/demucs#egg=demucs
2
- scipy
3
- invisible-watermark
4
- fonts
5
- font-roboto
 
6
 
7
 
 
1
+ # git+https://github.com/facebookresearch/demucs#egg=demucs
2
+ # scipy
3
+ # invisible-watermark
4
+ # fonts
5
+ # font-roboto
6
+ # gradio_client
7
 
8