def melspectrogram_torch(wav, hparams=None): """mel_output: torch.FloatTensor of shape (B, n_mel_channels, T)""" mel = melspectrogram(wav, hparams) mel_output = torch.from_numpy(mel).type(torch.FloatTensor) return mel_output
def files_to_list(filename): """ Takes a text file of filenames and makes a list of filenames """ with open(filename, encoding='utf-8') as f: files = f.readlines() files = [f.rstrip() for f in files] return files def to_gpu(x): x = x.contiguous() if torch.cuda.is_available(): x = x.cuda(non_blocking=True) return torch.autograd.Variable(x) if __name__ == "__main__": import aukit inpath = r"E:\data\temp\01.wav" wav = load_wav(inpath, sr=16000) mel = melspectrogram(wav) out = inv_melspectrogram(mel) aukit.play_audio(wav) aukit.play_audio(out)