-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_GCC_main.py
73 lines (59 loc) · 1.65 KB
/
test_GCC_main.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
62
63
64
65
66
67
68
69
70
71
72
73
# -*- coding=utf-8 -*-
''' TEST GCC'''
from localization import *
import re
def _num2str(num):
if num<10:
return '00'+str(num)
elif num<100:
return '0'+str(num)
else:
return str(num)
def getMatchFileList(org_list, noise_types, SNRs, index):
# get re strs
name_strs = []
if noise_types:
for noise_type in noise_types:
name_strs.append(r'.*'+noise_type+'_')
else:
name_strs.append(r'.*_')
name_strs_2 = []
if SNRs:
for snr in SNRs:
for prestr in name_strs:
name_strs_2.append(prestr+'snr'+str(snr)+r'_')
else:
for prestr in name_strs:
name_strs_2.append(prestr+r'snr\d+_')
name_strs_3 = []
if index:
for i in index:
for prestr in name_strs_2:
name_strs_3.append(prestr+r'.*_'+_num2str(i)+r'\..*')
else:
for prestr in name_strs_2:
name_strs_3.append(prestr+r'\..*')
# re match
pattern_list = []
for re_str in name_strs_3:
print re_str
pattern_list.append(re.compile(re_str))
test_list = []
for file in org_list:
for pattern in pattern_list:
if pattern.match(file):
test_list.append(file)
break
return test_list
def testGCC(dataset_dir=r'.\test_data\noise_test', SNRs=None, noise_types=None, \
index=None, frame_len=512, ref_power=None, weight_fun=None):
# according SNRs and noise_types find test dataset
all_files = wavlib.listWavFile(dataset_dir)
test_files = getMatchFileList(all_files, noise_types, SNRs, index)
for i in test_files:
print i
if __name__=='__main__':
SNRs = [20]
noise_types = []
index = []
testGCC(SNRs=SNRs, noise_types=noise_types, index=index)