|
import os |
|
import tempfile |
|
from audio_separator.separator import Separator |
|
|
|
separator = None |
|
|
|
def load_model(model = 'MDX23C-8KFFT-InstVoc_HQ.ckpt'): |
|
global separator |
|
|
|
separator = Separator() |
|
separator.load_model(model) |
|
|
|
def run(audio_path): |
|
global separator |
|
|
|
if not audio_path: |
|
return None, None |
|
|
|
primary_stem_output_path, secondary_stem_output_path = separator.separate(audio_path) |
|
|
|
return primary_stem_output_path, secondary_stem_output_path |
|
|
|
def raw(audio): |
|
with tempfile.NamedTemporaryFile(delete=True) as t: |
|
with open(t.name, 'w+b') as f: |
|
f.write(audio) |
|
|
|
return run(t.name) |
|
|