Example #1
0
 def __init__(self, save_dir, model_name, step=10, window=20, max_freq=8000, desc_file=None):
     """
     Params:
         step (int): Step size in milliseconds between windows
         window (int): FFT window size in milliseconds
         max_freq (int): Only FFT bins corresponding to frequencies between
             [0, max_freq] are returned
         desc_file (str, optional): Path to a JSON-line file that contains
             labels and paths to the audio files. If this is None, then
             load metadata right away
     """
     #calc_feat_dim returns int(0.001*window*max_freq)+1
     super(DataGenerator, self).__init__()
     # feat_dim=0.001*20*8000+1=161
     self.feat_dim = calc_feat_dim(window, max_freq)
     # 1d 161 length of array filled with zeros
     self.feats_mean = np.zeros((self.feat_dim,))
     # 1d 161 length of array filled with 1s
     self.feats_std = np.ones((self.feat_dim,))
     self.max_input_length = 0
     self.max_length_list_in_batch =[]
     # 1d 161 length of array filled with random value
     #[0.0, 1.0)
     self.rng = random.Random()
     if desc_file is not None:
         self.load_metadata_from_desc_file(desc_file)
     self.step = step
     self.window = window
     self.max_freq = max_freq
     self.save_dir = save_dir
     self.model_name = model_name
Example #2
0
 def __init__(self, save_dir, model_name, step=10, window=20, max_freq=8000, desc_file=None):
     """
     Params:
         step (int): Step size in milliseconds between windows
         window (int): FFT window size in milliseconds
         max_freq (int): Only FFT bins corresponding to frequencies between
             [0, max_freq] are returned
         desc_file (str, optional): Path to a JSON-line file that contains
             labels and paths to the audio files. If this is None, then
             load metadata right away
     """
     #calc_feat_dim returns int(0.001*window*max_freq)+1
     super(DataGenerator, self).__init__()
     # feat_dim=0.001*20*8000+1=161
     self.feat_dim = calc_feat_dim(window, max_freq)
     # 1d 161 length of array filled with zeros
     self.feats_mean = np.zeros((self.feat_dim,))
     # 1d 161 length of array filled with 1s
     self.feats_std = np.ones((self.feat_dim,))
     self.max_input_length = 0
     self.max_length_list_in_batch = []
     # 1d 161 length of array filled with random value
     #[0.0, 1.0)
     self.rng = random.Random()
     if desc_file is not None:
         self.load_metadata_from_desc_file(desc_file)
     self.step = step
     self.window = window
     self.max_freq = max_freq
     self.save_dir = save_dir
     self.model_name = model_name