Files
TTS/tests/vocoder_tests/test_vocoder_pqmf.py

27 lines
687 B
Python
Raw Permalink Normal View History

import os
import soundfile as sf
2021-04-12 11:47:39 +02:00
import torch
from librosa.core import load
2021-04-12 11:47:39 +02:00
from tests import get_tests_input_path, get_tests_output_path, get_tests_path
2020-09-09 12:27:23 +02:00
from TTS.vocoder.layers.pqmf import PQMF
TESTS_PATH = get_tests_path()
WAV_FILE = os.path.join(get_tests_input_path(), "example_1.wav")
def test_pqmf():
w, sr = load(WAV_FILE)
layer = PQMF(N=4, taps=62, cutoff=0.15, beta=9.0)
w, sr = load(WAV_FILE)
w2 = torch.from_numpy(w[None, None, :])
b2 = layer.analysis(w2)
w2_ = layer.synthesis(b2)
print(w2_.max())
print(w2_.min())
print(w2_.mean())
2021-04-12 11:47:39 +02:00
sf.write(os.path.join(get_tests_output_path(), "pqmf_output.wav"), w2_.flatten().detach(), sr)