-
Notifications
You must be signed in to change notification settings - Fork 99
/
apply_dct.py
30 lines (23 loc) · 918 Bytes
/
apply_dct.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
"""
read in 256 dimension cpc features --> apply dct --> store 23 dimension feature
requirement: Kaldi
"""
import scipy.fftpack as fft
import src.kaldi_io as ko
import argparse
def main():
## Settings
parser = argparse.ArgumentParser(description='PyTorch MNIST Example')
parser.add_argument('--input-scp')
parser.add_argument('--output-scp')
parser.add_argument('--output-ark')
parser.add_argument('--dct-dim', type=int)
args = parser.parse_args()
ark_scp_output='ark:| copy-feats --compress=true ark:- ark,scp:' + args.output_ark + ',' + args.output_scp
with ko.open_or_fd(ark_scp_output,'wb') as f:
for key, mat in ko.read_mat_scp(args.input_scp):
dct_mat = fft.dct(mat, type=2, n=args.dct_dim)
ko.write_mat(f, dct_mat, key=key)
print('#################success#################')
if __name__ == '__main__':
main()