def _load_or_generate_phoneme_sequence(wav_file, text, phoneme_cache_path, enable_eos_bos, cleaners, language, custom_symbols, characters, add_blank): file_name = os.path.splitext(os.path.basename(wav_file))[0] # different names for normal phonemes and with blank chars. file_name_ext = "_blanked_phoneme.npy" if add_blank else "_phoneme.npy" cache_path = os.path.join(phoneme_cache_path, file_name + file_name_ext) try: phonemes = np.load(cache_path) except FileNotFoundError: phonemes = TTSDataset._generate_and_cache_phoneme_sequence( text, cache_path, cleaners, language, custom_symbols, characters, add_blank) except (ValueError, IOError): print(" [!] failed loading phonemes for {}. " "Recomputing.".format(wav_file)) phonemes = TTSDataset._generate_and_cache_phoneme_sequence( text, cache_path, cleaners, language, custom_symbols, characters, add_blank) if enable_eos_bos: phonemes = pad_with_eos_bos(phonemes, tp=characters) phonemes = np.asarray(phonemes, dtype=np.int32) return phonemes
def _load_or_generate_phoneme_sequence(self, wav_file, text): file_name = os.path.splitext(os.path.basename(wav_file))[0] cache_path = os.path.join(self.phoneme_cache_path, file_name + '_phoneme.npy') try: phonemes = np.load(cache_path) except FileNotFoundError: phonemes = self._generate_and_cache_phoneme_sequence( text, cache_path) except (ValueError, IOError): print(" > ERROR: failed loading phonemes for {}. " "Recomputing.".format(wav_file)) phonemes = self._generate_and_cache_phoneme_sequence( text, cache_path) if self.enable_eos_bos: phonemes = pad_with_eos_bos(phonemes, tp=self.tp) phonemes = np.asarray(phonemes, dtype=np.int32) return phonemes