Exemple #1
0
 def inference_from_path(self):
     src_mel, _ = get_spectrograms(self.args.source)
     tar_mel, _ = get_spectrograms(self.args.target)
     src_mel = torch.from_numpy(self.normalize(src_mel)).cuda()
     tar_mel = torch.from_numpy(self.normalize(tar_mel)).cuda()
     conv_wav, conv_mel = self.inference_one_utterance(src_mel, tar_mel)
     self.write_wav_to_file(conv_wav, self.args.output)
     return
 def convert_from_path(self, srcpath, trgpath, opath, device_id):
     #print(f"Running on device {device_id}")
     os.environ["CUDA_VISIBLE_DEVICES"] = str(device_id)
     src_mel, _ = get_spectrograms(srcpath)
     tar_mel, _ = get_spectrograms(trgpath)
     src_mel = torch.from_numpy(self.normalize(src_mel)).cuda()
     tar_mel = torch.from_numpy(self.normalize(tar_mel)).cuda()
     conv_wav, conv_mel = self.convert_one_utterance(src_mel, tar_mel)
     self.write_wav_to_file(conv_wav, opath)
     return
Exemple #3
0
    def inference_form_path_multi_target(self, target_path_list, save=False):
        src_mel, _ = get_spectrograms(self.args.source)
        src_mel = torch.from_numpy(self.normalize(src_mel))

        tar_mel_list = []
        for target_path in target_path_list:
            tar_mel, _ = get_spectrograms(target_path)
            tar_mel = torch.from_numpy(self.normalize(tar_mel))
            tar_mel_list.append(tar_mel)

        conv_wav, conv_mel = self.inference_one_utterance_multi_target(
            src_mel, tar_mel_list)
        if save:
            self.write_wav_to_file(conv_wav, self.args.output)
        return conv_wav
Exemple #4
0
 def inference_one_utterance_spk(self, uttpath):
     x, _ = get_spectrograms(uttpath)
     x = torch.from_numpy(self.normalize(x)).cuda()
     x = self.utt_make_frames(x)
     emb = self.model.get_speaker_embeddings(x)
     emb = emb.detach().cpu().numpy()
     return emb
Exemple #5
0
 def inference_one_utterance_content(self, uttpath):
     x, _ = get_spectrograms(uttpath)
     x = torch.from_numpy(self.normalize(x)).cuda()
     x = self.utt_make_frames(x)
     emb = self.model.get_content_repr(x)
     emb = emb.detach().cpu().numpy()
     emb = np.mean(emb, axis=2)
     return emb
 def get_mel_frames(self, apath):
     tar_mel_frames, _ = get_spectrograms(apath)
     tar_mel_frames = torch.from_numpy(
         self.normalize(tar_mel_frames)).cuda()
     tar_mel_frames = self.utt_make_frames(tar_mel_frames)
     return tar_mel_frames