def not_relaxed_music_remix(self, pos_arous_dir, files, decisions):
sounds = []
for i in range(len(pos_arous_dir)):
for subdirs, dirs, s in os.walk(pos_arous_dir[i]):
sounds.append(subdirs + '/' + random.choice(s))
fx = random.choice(sounds[::-1])
fy = random.choice(sounds[:])
x = MonoLoader(filename = fx)()
y = MonoLoader(filename = fy)()
fx = fx.split('/')[1].split('.')[0]
fy = fy.split('/')[1].split('.')[0]
fx = np.where(files == fx)[0]
fy = np.where(files == fy)[0]
dec_x = get_coordinate(fx, choice([0,1,3]), decisions)
dec_y = get_coordinate(fy, choice([0,1,3]), decisions)
x = self.source_separation(x)
x = scratch_music(x, dec_x)
y = scratch_music(y, dec_y)
x = x[np.nonzero(x)]
y = y[np.nonzero(y)]
x, y = same_time(x,y)
morph = stft.morph(x1 = x,x2 = y,fs = 44100,w1=np.hanning(1025),N1=2048,w2=np.hanning(1025),N2=2048,H1=512,smoothf=0.01,balancef=0.7)
interv = RhythmExtractor2013()(np.float32(morph))[1] * 44100
steps = overlapped_intervals(interv)
output = librosa.effects.remix(morph, steps[::-1], align_zeros = False)
output = librosa.effects.pitch_shift(output, sr = 44100, n_steps = 3)
remix_filename = 'data/emotions/remixes/not relaxed/'+str(time.strftime("%Y%m%d-%H:%M:%S"))+'multitag_remix.ogg'
MonoWriter(filename = remix_filename, sampleRate = 44100, format = 'ogg')(np.float32(output))
subprocess.call(["ffplay", "-nodisp", "-autoexit", remix_filename])
评论列表
文章目录