Пример #1
0
    def __getitem__(self, idx):
        if idx in self.cache_Dict.keys():
            return self.cache_Dict[idx]
        
        content_Label, content_Path, style_Label, style_Path = self.pattern_List[idx]
        content_Mel = Mel_Generate(
            audio= Audio_Prep(content_Path, hp_Dict['Sound']['Sample_Rate']),
            sample_rate= hp_Dict['Sound']['Sample_Rate'],
            num_frequency= hp_Dict['Sound']['Spectrogram_Dim'],
            num_mel= hp_Dict['Sound']['Mel_Dim'],
            window_length= hp_Dict['Sound']['Frame_Length'],
            hop_length= hp_Dict['Sound']['Frame_Shift'],        
            mel_fmin= hp_Dict['Sound']['Mel_F_Min'],
            mel_fmax= hp_Dict['Sound']['Mel_F_Max'],
            max_abs_value= hp_Dict['Sound']['Max_Abs_Mel']
            )
        style_Mel = Mel_Generate(
            audio= Audio_Prep(style_Path, hp_Dict['Sound']['Sample_Rate']),
            sample_rate= hp_Dict['Sound']['Sample_Rate'],
            num_frequency= hp_Dict['Sound']['Spectrogram_Dim'],
            num_mel= hp_Dict['Sound']['Mel_Dim'],
            window_length= hp_Dict['Sound']['Frame_Length'],
            hop_length= hp_Dict['Sound']['Frame_Shift'],        
            mel_fmin= hp_Dict['Sound']['Mel_F_Min'],
            mel_fmax= hp_Dict['Sound']['Mel_F_Max'],
            max_abs_value= hp_Dict['Sound']['Max_Abs_Mel']
            )
        pattern = content_Mel, style_Mel, content_Label, style_Label

        if hp_Dict['Train']['Use_Pattern_Cache']:
            self.cache_Dict[idx] = pattern
 
        return pattern
Пример #2
0
def Pattern_Generate(audio=None,
                     path=None,
                     keyword_Index_Dict=None,
                     top_db=60,
                     reverse=False,
                     invert=False):
    audio = audio if not audio is None else Audio_Prep(
        path, hp_Dict['Sound']['Sample_Rate'], top_db)
    if reverse:
        audio = audio[::-1]
    if invert:
        audio = -audio

    mel = Mel_Generate(audio=audio,
                       sample_rate=hp_Dict['Sound']['Sample_Rate'],
                       num_frequency=hp_Dict['Sound']['Spectrogram_Dim'],
                       num_mel=hp_Dict['Sound']['Mel_Dim'],
                       window_length=hp_Dict['Sound']['Frame_Length'],
                       hop_length=hp_Dict['Sound']['Frame_Shift'],
                       mel_fmin=hp_Dict['Sound']['Mel_F_Min'],
                       mel_fmax=hp_Dict['Sound']['Mel_F_Max'],
                       max_abs_value=hp_Dict['Sound']['Max_Abs_Mel'])
    pitch = Pitch_Generate(audio)

    singer_ID = None
    if not keyword_Index_Dict is None:
        for keyword, index in keyword_Index_Dict.items():
            if keyword in path:
                singer_ID = index
                break
        if singer_ID is None:
            raise ValueError('No keyword in keyword_Index_Dict.')

    return audio, mel, pitch, singer_ID
Пример #3
0
def Pattern_Generate(path, top_db=60):
    audio = Audio_Prep(path, hp_Dict['Sound']['Sample_Rate'], top_db)
    mel = Mel_Generate(audio=audio,
                       sample_rate=hp_Dict['Sound']['Sample_Rate'],
                       num_frequency=hp_Dict['Sound']['Spectrogram_Dim'],
                       num_mel=hp_Dict['Sound']['Mel_Dim'],
                       window_length=hp_Dict['Sound']['Frame_Length'],
                       hop_length=hp_Dict['Sound']['Frame_Shift'],
                       mel_fmin=hp_Dict['Sound']['Mel_F_Min'],
                       mel_fmax=hp_Dict['Sound']['Mel_F_Max'],
                       max_abs_value=hp_Dict['Sound']['Max_Abs_Mel'])

    return audio, mel
Пример #4
0
def Pattern_Generate(path, top_db=60):
    audio = Audio_Prep(path, hp.Sound.Sample_Rate, top_db)
    mel = Mel_Generate(audio=audio,
                       sample_rate=hp.Sound.Sample_Rate,
                       num_frequency=hp.Sound.Spectrogram_Dim,
                       num_mel=hp.Sound.Mel_Dim,
                       window_length=hp.Sound.Frame_Length,
                       hop_length=hp.Sound.Frame_Shift,
                       mel_fmin=hp.Sound.Mel_F_Min,
                       mel_fmax=hp.Sound.Mel_F_Max,
                       max_abs_value=hp.Sound.Max_Abs_Mel)
    pitch = Pitch_Generate(audio)

    return audio, mel, pitch
Пример #5
0
    def __getitem__(self, idx):
        label, file = self.patterns[idx]
        noisy = Audio_Prep(file, sample_rate=self.sample_Rate)

        return noisy, label
Пример #6
0
    def __getitem__(self, idx):
        audio = Audio_Prep(self.files[idx], sample_rate=self.sample_Rate)
        noise = Audio_Prep(choice(self.noises), sample_rate=self.sample_Rate)

        return audio, noise