Exemplo n.º 1
0
    def __init__(self,
                 path,
                 save_conversion_params=False,
                 to_list=False,
                 meta_prep_f=None):

        super().__init__(path,
                         save_conversion_params=False,
                         to_list=to_list,
                         meta_prep_f=meta_prep_f)

        song_iter = self.get_chords_together(with_metaData=False)

        _, self.label_d = label([
            chord for instruments in song_iter for s in instruments
            for bar in s for chord in bar
        ],
                                start=0)

        self.V = len(self.label_d)
        if save_conversion_params:
            self.conversion_params["chords"] = self.label_d
            self.save_conversion_params(filename=save_conversion_params +
                                        "/ChordGenerator.conversion_params")

        self.melody_gen = MelodyGenerator(path,
                                          save_conversion_params=False,
                                          to_list=to_list,
                                          meta_prep_f=None)
Exemplo n.º 2
0
    def __init__(self, path, save_conversion_params=True):
        super().__init__(path, save_conversion_params=save_conversion_params)
        song_iter = self.get_rhythms(with_metaData=False)
        label_f, self.label_d = label(
            [beat for s in song_iter for bar in s for beat in bar], start=0)

        self.null_elem = ()
        self.V = len(self.label_d)
        self.conversion_params["rhythm"] = self.label_d
        if self.save_params_eager:
            self.save_conversion_params()
Exemplo n.º 3
0
    def __init__(self,
                 path,
                 save_conversion_params=True,
                 to_list=False,
                 meta_prep_f=None):
        super().__init__(path,
                         save_conversion_params=save_conversion_params,
                         to_list=to_list,
                         meta_prep_f=meta_prep_f)
        song_iter = self.get_rhythms_together(with_metaData=False)
        label_f, self.label_d = label([
            beat for instruments in song_iter for s in instruments for bar in s
            for beat in bar
        ],
                                      start=0)

        self.null_elem = ()
        self.V = len(self.label_d)
        self.conversion_params["rhythm"] = self.label_d
        if self.save_params_eager:
            self.save_conversion_params()
Exemplo n.º 4
0
from Data.DataGenerators import RhythmGenerator
from Nets.RhythmNetwork import RhythmNetwork

import pickle
import numpy.random as rand
from Data.utils import label


#%%
        
with open("bach_beats.pkl", "rb") as handle:
    data = pickle.load(handle)

data = rand.permutation(data)
parts = [list(map(tuple, part)) for score in data for part in score]
_, label_d = label([b for p in parts for b in p], start=1)
pad_symb = "<s>"
label_d[pad_symb] = 0

#%%
r = RhythmGenerator(4, label_d, "<s>")

r_gen = r.generate_data(parts, shuffle=False)

#%%
rnet = RhythmNetwork(num_categories=len(label_d),
                     embed_size=32,
                     lstm_size=64)
#%%
rnet.fit_generator(r_gen, steps_per_epoch=len(parts), epochs=1)