forked from georgesterpu/pyVSR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_dct.py
61 lines (52 loc) · 1.5 KB
/
example_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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import pyVSR
from os import path
from pyVSR import tcdtimit
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
def main():
dataset_dir = '/run/media/john_tukey/download/datasets/adapt/tcdtimit/'
train, test = tcdtimit.files.request_files(
dataset_dir=dataset_dir,
protocol='speaker_dependent',
remove_sa=True)
file_dict = dict()
output_dir = './run/features/roi/'
for file in (train+test):
file_dict[file] = path.join(
output_dir,
path.splitext(file.split('tcdtimit/')[-1])[0] + '.h5')
experiment = pyVSR.AVSR(num_threads=4)
experiment.extract_save_features(
files=file_dict,
feature_type='roi',
extract_opts={
'align': True,
'gpu': True,
'color': True,
'border': 15,
'window_size': (36, 36),
},
)
feat_dict = dict()
outdir = './run/features/dct/'
for file in file_dict.values():
feat_dict[file] = path.join(
outdir,
path.splitext(file.split('roi/')[-1])[0] + '.htk'
)
experiment.process_features_write_htk(
files=feat_dict,
feature_type='dct',
process_opts={
'compute_dct': True,
'mask': '1-44',
'keep_basis': True,
'delta': True,
'double_delta': True,
'derivative_order': 'first',
'interpolation_factor': 1,
},
frame_rate=30,
)
if __name__ == "__main__":
main()