forked from Xiao-Ming/UNet-VocalSeparation-Chainer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProcessIKALA.py
47 lines (35 loc) · 1.05 KB
/
ProcessIKALA.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Nov 3 11:49:54 2017
@author: wuyiming
"""
import numpy as np
from librosa.util import find_files
from librosa.core import load
import os.path
import util
PATH_iKala = "iKala/Wavfile"
audiolist = find_files(PATH_iKala, ext="wav")
for audiofile in audiolist:
fname = os.path.split(audiofile)[-1]
print("Processing: %s" % fname)
y, _ = load(audiofile, sr=None, mono=False)
inst = y[0, :]
mix = y[0, :]+y[1, :]
vocal = y[1, :]
util.SaveSpectrogram(mix, vocal, inst, fname)
print("Constructing random mix...")
rand = np.random.randint(len(audiolist), size=40)
count = 1
for i in range(0, 40, 2):
y1, _ = load(audiolist[rand[i]], sr=None, mono=False)
y2, _ = load(audiolist[rand[i+1]], sr=None, mono=False)
minlen = min([y1.shape[1], y2.shape[1]])
inst = y1[0, :minlen]
vocal = y2[1, :minlen]
mix = inst+vocal
fname = "ikala_random%02d" % count
util.SaveSpectrogram(mix, vocal, inst, fname)
count += 1
print("Saved %s.npz" % fname)