def test_audio_griffinlim(): from aukit.audio_griffinlim import inv_linear_spectrogram, inv_linear_spectrogram_tf, inv_mel_spectrogram from aukit.audio_griffinlim import default_hparams as hparams_griffinlim from aukit.audio_spectrogram import linear_spectrogram, mel_spectrogram out_linear = linear_spectrogram(_wav, hparams=hparams_griffinlim) out_wav = inv_linear_spectrogram(out_linear, hparams=hparams_griffinlim) assert out_wav.shape == (800, ) out_mel = mel_spectrogram(_wav, hparams=hparams_griffinlim) out_wav = inv_mel_spectrogram(out_mel, hparams=hparams_griffinlim) assert out_wav.shape == (800, )
def run_spectrogram(): from aukit import audio_spectrogram as asp from aukit import audio_griffinlim as agf from aukit import audio_io as aio from aukit.audio_player import play_audio inpath = r"E:/data/temp/01.wav" wav, sr = aio.load_wav(inpath, with_sr=True) print(wav.shape, sr) play_audio(wav, sr) lin_gf = agf.linear_spectrogram(wav) wav_gf = agf.inv_linear_spectrogram(lin_gf) play_audio(wav_gf, sr) mel_sp = asp.mel_spectrogram(wav) mel_sp = asp.mel2linear_spectrogram(mel_sp) wav_sp = agf.inv_linear_spectrogram(mel_sp) play_audio(wav_sp, sr) linear_gf = agf.linear_spectrogram(wav) mel_lin = agf.linear2mel_spectrogram(linear_gf) linear_mel = agf.mel2linear_spectrogram(mel_lin) wav_2 = agf.inv_linear_spectrogram(linear_mel) mel_sp = asp.mel_spectrogram(wav) mel_fea = asp.mel_spectrogram_feature(wav) # plt.figure() # plt.subplot("311") # plt.pcolor(linear) # plt.subplot("312") # plt.pcolor(linear2) # plt.subplot("313") # plt.pcolor(mel_fea) # plt.show() wav_ms = agf.inv_mel_spectrogram(mel_sp) wav_mf = agf.inv_mel_spectrogram(mel_fea) play_audio(wav_ms, sr) play_audio(wav_mf, sr)
def test_audio_spectrogram(): from aukit.audio_spectrogram import linear_spectrogram, mel_spectrogram from aukit.audio_spectrogram import default_hparams as hparams_spectrogram from aukit.audio_spectrogram import linear2mel_spectrogram, mel2linear_spectrogram out_linear = linear_spectrogram(_wav, hparams=hparams_spectrogram) assert out_linear.shape == (401, 5) out_mel = mel_spectrogram(_wav, hparams=hparams_spectrogram) assert out_mel.shape == (80, 5) out_mel_from_linear = linear2mel_spectrogram(out_linear, hparams=hparams_spectrogram) assert out_mel_from_linear.shape == (80, 5) out_linear_from_mel = mel2linear_spectrogram(out_mel, hparams=hparams_spectrogram) assert out_linear_from_mel.shape == (401, 5)
def melspectrogram(wav, hparams=None): wav = np.pad(wav.flatten(), (_pad_len, _pad_len), mode="reflect") mel = mel_spectrogram(wav, melgan_hparams) mel = mel / 20 return mel