-
Notifications
You must be signed in to change notification settings - Fork 70
/
how_to_get_pfile.txt
75 lines (60 loc) · 3.3 KB
/
how_to_get_pfile.txt
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
74
###############################################################################################
# detailed steps for get pfile
# step1: used the tool "Wav2LogSpec.exe" to extract all ".lsp" files from raw audio files. (RAW means no header, there is header info in wav format audio files, help/wav2raw.exe can delete the header info)
# step2: use "toolbox/le2be.m" to convert the little endian (le) ".lsp" features into big endian (be) ".lsp_be" features. Here it is a little tricky, maybe you can find some better ways.
# step3: use "toolbox/randomlist.pl" to rand your scp lists
# step4: prepare ".len" TXT file (the frame number of each ".lsp" file, one number on each line). You can use #"toolbox/getlenscp.exe in.scp out.len"
#".len" example:
#120
#234
#451
#99
#...
# step5: use the ".scp (be format feature files, not le format feature files)" and ".len" to get pfile as following.
# summary: "Wav2LogSpec.exe" only can extract "little endian (le)" format feautres from RAW audio files. But quicknet tools only accept "big endian (be)" feature files. So that is why you need "le2be". Normally, HTK toolset (like HCopy.exe) can directly extract "be" formart features (log-power spectra), but i never try it.
# summary: here it is a little tricky and ugly, i am planing to re-write all of the DNN-SE stuff based on Tensorflow.
#############################################################################
# An example for a Perl script to get a PFile
# Quicknet tool set is here: http://www1.icsi.berkeley.edu/Speech/qn.html
# http://www1.icsi.berkeley.edu/Speech/icsi-speech-tools.html
#############################################################################
#!/usr/local/bin/perl -w
#attentions: please confirm that all the input files from windows system are converted from DOS to UNIX
#attentions: please add path: export PATH=$PATH:/home/xxx/tools/QN/basic/bin
my $ROOT_DIR = "/disk4/yongxu_d4/get_timit_labpfile/lib";
my $TOOL_DIR = "/home/yongxu/tools/QN/atlas1/bin";
my $CF_DIR = "$ROOT_DIR";
my $len_scp = "$CF_DIR/timit_115NT_7SNRs_each190utts_clean_lab_be_random_linux.len"; ### frame number for each feature file
my $fea_scp = "$CF_DIR/timit_115NT_7SNRs_each190utts_clean_lab_be_random_linux.scp"; ### feature file path for each feature file, *.len should be corresponding to the *.scp file (in the same order)
my $fea_tr = "$CF_DIR/timit_115NT_7SNRs_each190utts_clean_lab_be_random_linux.pfile"; ### output big pfile
my $part_num = 9693; ### how many utterances for each parallel part
my $split_num = 10; #46980*4=187920 utts ### parallel computing in 10 parts
my $i;
my @pid;
my $pfile_list;
print "ok\n";
system("split -l $part_num -d -a 1 $fea_scp $fea_scp");
system("split -l $part_num -d -a 1 $len_scp $len_scp");
foreach $i (0..$split_num-1)
{
defined($pid[$i] = fork) or die "can't fork: $!";
unless ($pid[$i])
{
system("$TOOL_DIR/feacat -period 16.0 -ipformat htk -deslenfile $len_scp$i -lists -o $fea_tr$i $fea_scp$i");### frame shift = 16ms, attention here
exit(0);
}
}
$pfile_list = "";
foreach $i (0..$split_num-1)
{
waitpid($pid[$i], 0);
$pfile_list = $pfile_list . "$fea_tr$i ";
}
system("$TOOL_DIR/pfile_concat -o $fea_tr $pfile_list");
##foreach $i (0..$split_num-1)
##{
## system("rm -rf $fea_scp$i");
## system("rm -rf $len_scp$i");
## system("rm -rf $fea_tr$i");
##}
##system("rm -rf $fea_lst");