File size: 630 Bytes
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():
    global separator

    separator = Separator()
    separator.load_model('Kim_Vocal_2.onnx')
    
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)