musicgowdam commited on
Commit
981b156
·
verified ·
1 Parent(s): 66719e8

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +6 -7
  2. app.py +31 -0
  3. requirements.txt +8 -0
README.md CHANGED
@@ -1,14 +1,13 @@
1
  ---
2
- title: Audio Stem Extractor-1
3
- emoji: 📈
4
- colorFrom: gray
5
- colorTo: indigo
6
  sdk: gradio
7
- sdk_version: 5.49.0
8
  app_file: app.py
9
  pinned: false
10
- license: mit
11
- short_description: Audio_stem_Extractor_2
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Vocal Extractor
3
+ emoji: 🎤️
4
+ colorFrom: red
5
+ colorTo: red
6
  sdk: gradio
7
+ sdk_version: 5.47.2
8
  app_file: app.py
9
  pinned: false
10
+ short_description: Extracting Vocal part from songs
 
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from scipy.io.wavfile import write
4
+ from pydub import AudioSegment
5
+
6
+ def wav_to_mp3(wav_path, mp3_path, bitrate="128k"): # 128k is a good default for quality/compression
7
+ audio = AudioSegment.from_wav(wav_path)
8
+ audio.export(mp3_path, format="mp3", bitrate=bitrate)
9
+
10
+ def inference(audio):
11
+ os.makedirs("out", exist_ok=True)
12
+ write('test.wav', audio[0], audio[1])
13
+ os.system("python3 -m demucs.separate -n htdemucs --two-stems=vocals test.wav -o out")
14
+ vocals_wav = "./out/htdemucs/test/vocals.wav"
15
+ no_vocals_wav = "./out/htdemucs/test/no_vocals.wav"
16
+ vocals_mp3 = "./out/htdemucs/test/vocals.mp3"
17
+ no_vocals_mp3 = "./out/htdemucs/test/no_vocals.mp3"
18
+ wav_to_mp3(vocals_wav, vocals_mp3)
19
+ wav_to_mp3(no_vocals_wav, no_vocals_mp3)
20
+ return vocals_mp3, no_vocals_mp3
21
+
22
+ title = "Demucs Music Source Separation (v4)"
23
+ 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>"
24
+
25
+ gr.Interface(
26
+ inference,
27
+ gr.Audio(type="numpy", label="Input"),
28
+ [gr.Audio(type="filepath", label="Vocals"),gr.Audio(type="filepath", label="No Vocals / Instrumental")],
29
+ title=title,
30
+ article=article,
31
+ ).launch()
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ git+https://github.com/facebookresearch/demucs#egg=demucs
2
+ scipy
3
+ invisible-watermark
4
+ fonts
5
+ font-roboto
6
+ numpy<1.26
7
+ pydub
8
+