File size: 1,673 Bytes
9ed779b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8d873bc
 
9ed779b
 
 
 
 
 
69b70a3
9bfe938
15e17ac
9ed779b
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from spleeter.separator import Separator
import gradio as gr
import shutil


def spleeter(aud, instrument):
  separator = Separator('spleeter:2stems')
  try:
    shutil.rmtree("output")
  except FileNotFoundError:
    pass
  separator.separate_to_file(aud.name, "output/", filename_format="audio_example/{instrument}.wav")
  return f"./output/audio_example/{instrument}.wav", f"./output/audio_example/{instrument}.wav"

inputs = [
          gr.inputs.Audio(label="Input Audio File", type="file"),
          gr.inputs.Radio(label="Output", choices=["accompaniment", "vocals"], type="value")
]
outputs =  [
  gr.outputs.Audio(label="Output Audio", type="file"),
  gr.outputs.File(label="Output File")
]

title = "Music Spleeter"
description = "Clearing a musical composition of the performer's voice is a common task. It is solved well, for example, by professional audio file editing programs. AI algorithms have also been gaining ground recently."
article = "<div style='text-align: center; max-width:800px; margin:10px auto;'><p>In this case we use Deezer's Spleeter with ready pretrained models. It can leave as an output both just the music and just the performer's voice.</p><p>Sources: <a href='https://github.com/deezer/spleeter/' target='_blank'>Spleeter</a>: a Fast and Efficient Music Source Separation Tool with Pre-Trained Models</p><p style='text-align: center'><a href='https://starstat.yt/cat/music' target='_blank'>StarStat Music</a>: Youtubers Net Worth in category Music</p></div>"
examples = [
    ["audio_example.mp3", "vocals"]
]

gr.Interface(spleeter, inputs, outputs, title=title, description=description, article=article, examples=examples).launch()