-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbaseline.py
39 lines (33 loc) · 1011 Bytes
/
baseline.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
36
37
38
39
# this code is used to
# get xvector.ark from xvector.npz and
# calculate baseline EER
import numpy as np
import tensorflow as tf
import os
paths = ["./data/voxceleb_combined_200000/xvector",
"./data/sitw_dev/enroll/xvector",
"./data/sitw_dev/test/xvector",
"./data/sitw_eval/enroll/xvector",
"./data/sitw_eval/test/xvector"
]
# delete
for path in paths:
if os.path.exists(path+'.ark') == True:
os.remove(path+'.ark')
print('delete {}.ark'.format(path))
# write
for path in paths:
# load npz data
vector = np.load(path+'.npz')['vector']
labels = np.load(path+'.npz')['utt']
with open(path+'.ark', 'w') as f:
for i in range(vector.shape[0]):
f.write(str(labels[i]))
f.write(' [ ')
for j in vector[i]:
f.write(str(j))
f.write(' ')
f.write(']')
f.write('\n')
print('{}.ark is done!'.format(path))
print('\nall done!')