File size: 655 Bytes
c7f5530
 
 
 
 
 
9c7dd22
c7f5530
 
 
9c7dd22
c7f5530
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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)