Offex commited on
Commit
7c090f2
·
verified ·
1 Parent(s): 64c7274

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import librosa
3
+ import numpy as np
4
+ import soundfile as sf
5
+
6
+ def vocal_remover(audio):
7
+ y, sr = librosa.load(audio, sr=None)
8
+
9
+ # Simple center-channel vocal suppression
10
+ S = librosa.stft(y)
11
+ left = S[:, :]
12
+ right = S[:, :]
13
+
14
+ vocals = (left - right) / 2
15
+ music = (left + right) / 2
16
+
17
+ vocals_audio = librosa.istft(vocals)
18
+ music_audio = librosa.istft(music)
19
+
20
+ sf.write("vocals.wav", vocals_audio, sr)
21
+ sf.write("music.wav", music_audio, sr)
22
+
23
+ return "vocals.wav", "music.wav"
24
+
25
+ interface = gr.Interface(
26
+ fn=vocal_remover,
27
+ inputs=gr.Audio(type="filepath", label="Upload Audio"),
28
+ outputs=[
29
+ gr.File(label="Vocals"),
30
+ gr.File(label="Music")
31
+ ],
32
+ title="AI Vocal Remover",
33
+ description="Upload audio & get vocals and music separated"
34
+ )
35
+
36
+ interface.launch()