Ahsen Khaliq commited on
Commit
2ed0e3a
·
1 Parent(s): 2336293

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from spleeter.separator import Separator
2
+ import gradio as gr
3
+ import shutil
4
+
5
+ def spleeter(aud, instrument):
6
+ separator = Separator('spleeter:2stems')
7
+ try:
8
+ shutil.rmtree("output")
9
+ except FileNotFoundError:
10
+ pass
11
+ separator.separate_to_file(aud.name, "output/", filename_format="audio_example/{instrument}.wav")
12
+ return f"./output/audio_example/{instrument}.wav", f"./output/audio_example/{instrument}.wav"
13
+
14
+ inputs = [
15
+ gr.inputs.Audio(label="Input Audio", type="file"),
16
+ gr.inputs.Radio(label="Instrument", choices=["vocals", "accompaniment"], type="value")
17
+ ]
18
+ outputs = [
19
+ gr.outputs.Audio(label="Output Audio", type="file"),
20
+ gr.outputs.File(label="Output File")
21
+ ]
22
+
23
+ title = "Spleeter"
24
+ description = "demo for Spleeter by Deezer. To use it, simply upload your audio, or click one of the examples to load them. Read more at the links below."
25
+ article = "<p style='text-align: center'><a href='https://research.deezer.com/projects/spleeter.html'>Spleeter: a Fast and Efficient Music Source Separation Tool with Pre-Trained Models</a> | <a href='https://github.com/deezer/spleeter'>Github Repo</a></p>"
26
+ examples = [
27
+ ["audio_example.mp3"]
28
+ ]
29
+
30
+ gr.Interface(spleeter, inputs, outputs, title=title, description=description, article=article, examples=examples).launch()