Exemplo n.º 1
0
 def test_scale_y_max(self):
     random.seed(1)
     sampwidth = 2
     mock_wave = build_mock_wave(sampwidth=sampwidth)
     wd = WavDecoder("filename", decoder_class=mock_wave, max_height=1000)
     wd.open()
     test_y = 2**(sampwidth*8)
     expected_y = 1000
     self.assertAlmostEqual(wd.scale_y(test_y), expected_y)
Exemplo n.º 2
0
 def test_scale_x_min(self):
     random.seed(1)
     nframes = 10
     mock_wave = build_mock_wave(nframes=nframes)
     wd = WavDecoder("filename", decoder_class=mock_wave, max_width=100)
     wd.open()
     for i in range(0, 100):
         rand_x = random.randint(0, nframes)
         self.assertAlmostEqual(wd.scale_x(rand_x), rand_x)
Exemplo n.º 3
0
 def test_scale_x_shrink(self):
     random.seed(1)
     nframes = 1000
     mock_wave = build_mock_wave(nframes=nframes)
     wd = WavDecoder("filename", decoder_class=mock_wave, max_width=100)
     wd.open()
     scale = wd.width/nframes
     for i in range(0, 100):
         rand_x = random.randint(0, nframes)
         expected_x = rand_x * scale
         self.assertAlmostEqual(wd.scale_x(rand_x), expected_x)
Exemplo n.º 4
0
 def test_scale_y(self):
     random.seed(1)
     sampwidth = 2
     max_height = 2**(sampwidth*8 - 1)
     mock_wave = build_mock_wave(sampwidth=sampwidth)
     wd = WavDecoder("filename", decoder_class=mock_wave, max_height=1000)
     wd.open()
     scale = wd.height/max_height
     for i in range(0, 100):
         rand_y = random.randint(0, max_height)
         expected_y = rand_y * scale/2
         self.assertAlmostEqual(wd.scale_y(rand_y), expected_y)
Exemplo n.º 5
0
 def test_scale_y_8_bit(self):
     random.seed(1)
     sampwidth = 1
     max_height = 2**8
     mock_wave = build_mock_wave(sampwidth=sampwidth)
     wd = WavDecoder("filename", decoder_class=mock_wave, max_height=100,
                     signed=False)
     wd.open()
     wd.deocder = wave
     scale = wd.height/max_height
     for i in range(0, 100):
         rand_y = random.randint(0, max_height)
         expected_y = (rand_y-128) * scale
         self.assertAlmostEqual(wd.scale_y(rand_y), expected_y)
Exemplo n.º 6
0
import os, json
from wav2vec import WavDecoder

master_list = {}
part_number = 1

for i, file in enumerate(os.listdir("MELD.Raw/test_wav")):
    if i > 0 and i % 100 == 0:
        json.dump(master_list,
                  open("json_parts_test/part{}.json".format(part_number), "w"))
        part_number += 1
        master_list = {}
        print("Part written")

    wd = WavDecoder(os.path.join("wav", file))
    frames = []
    for f in wd:
        frames.append(f)
    ys = [p.y for p in frames[0][0]]
    master_list[file.split(".")[0]] = ys[:10000]
    if i % 100 == 0:
        print("{} done".format(i))
Exemplo n.º 7
0
 def test_endchar_for_aiff_is_bigendian(self):
     import aifc
     wd = WavDecoder("filename", decoder_class=aifc)
     self.assertEqual(wd.endchar, ">")
Exemplo n.º 8
0
 def setUp(self):
     mock_wave = build_mock_wave()
     self.wd = WavDecoder("filename", decoder_class=mock_wave)
Exemplo n.º 9
0
 def test_struct_fmt_char_big(self):
     for i in range(5, 12):
         mock_wave = build_mock_wave(sampwidth=i)
         wd = WavDecoder("filename", decoder_class=mock_wave)
         with self.assertRaises(ValueError):
             wd.open()
Exemplo n.º 10
0
 def test_struct_fmt_char_i(self):
     mock_wave = build_mock_wave(sampwidth=4)
     wd = WavDecoder("filename", decoder_class=mock_wave)
     wd.open()
     self.assertEqual(wd.struct_fmt_char, 'i')
Exemplo n.º 11
0
 def test_struct_fmt_char_b(self):
     mock_wave = build_mock_wave(sampwidth=1)
     wd = WavDecoder("filename", decoder_class=mock_wave, signed=True)
     wd.open()
     self.assertEqual(wd.struct_fmt_char, 'b')