-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtest_data.py
36 lines (27 loc) · 939 Bytes
/
test_data.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
30
31
32
33
34
35
import data
import pickle
sample_rate = 16000
frac_perm_use = 0.1
req_wav_buf_sz = 1e7
sam_file = '/home/henry/ai/data/librispeech.dev-clean.rdb'
n_batch = 4
input_size = 4000
output_size = 2000
sample_catalog = data.parse_sample_catalog(sam_file)
dwav = data.WavSlices(sample_catalog, sample_rate, frac_perm_use, req_wav_buf_sz)
dwav.set_geometry(n_batch, input_size, output_size)
batch_gen = dwav.batch_slice_gen_fn()
for i in range(1000):
__, voice_inds, wav = next(batch_gen)
# print(dwav, end='')
dwav_state = pickle.dumps(dwav)
print('Yielding: ', dwav, end='')
__, voice_inds, wav = next(batch_gen)
dwav_r = pickle.loads(dwav_state)
print('Restored: ', dwav_r, end='')
dwav_r.set_geometry(n_batch, input_size, output_size)
batch_gen_r = dwav_r.batch_slice_gen_fn()
print('Yielding: ', dwav_r, end='')
__, voice_inds_r, wav_r = next(batch_gen_r)
assert (voice_inds_r == voice_inds).all()
assert (wav_r == wav).all()