forked from samsad35/source-filter-vae
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_audiotools.py
31 lines (23 loc) · 1.01 KB
/
test_audiotools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import unittest
from sf_vae import AudioTools
class TestAudioTools(unittest.TestCase):
def test_load(self):
audio = AudioTools()
signal, rate = audio.load(path_wav=r"D:\These\data\Audio\LJSpeech-1.1\wavs\LJ001-0015.wav", resample=16000)
self.assertEqual(rate, 16000)
# audio.play(signal)
self.assertEqual(len(signal.shape), 1)
def test_stft(self):
audio = AudioTools()
signal, rate = audio.load(path_wav=r"D:\These\data\Audio\LJSpeech-1.1\wavs\LJ001-0015.wav", resample=16000)
mel, spec, phase = audio.stft(signal)
self.assertEqual(spec.shape[0], 513)
def test_istft(self):
audio = AudioTools()
signal, rate = audio.load(path_wav=r"D:\These\data\Audio\LJSpeech-1.1\wavs\LJ001-0015.wav", resample=16000)
mel, spec, phase = audio.stft(signal)
signal_ = audio.istft(spec, phase)
# audio.play(signal_)
self.assertEqual(signal_.shape, signal.shape)
if __name__ == '__main__':
unittest.main()