make_callfriend.pl
2.19 KB
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
75
#!/usr/bin/env perl
#
# Copyright 2014 David Snyder Daniel Povey
# Apache 2.0.
use File::Basename;
if (@ARGV != 3) {
print STDERR "Usage: $0 <path-to-LDC96S*> <language> <path-to-output>\n";
print STDERR "e.g. $0 /export/corpora5/LDC/LDC96S49 french data\n";
exit(1);
}
($db_base, $lang, $out_base_dir) = @ARGV;
$ldc_code = lc basename($db_base);
# We won't use the speaker or gender information. Anyway it's not that useful
# as it seems to be 2-wire recordings, and everything is mixed together.
foreach $set ('devtest', 'evltest', 'train') {
$tmp_dir = "$out_base_dir/tmp";
if (system("mkdir -p $tmp_dir") != 0) {
die "Error making directory $tmp_dir";
}
if (system("find $db_base -name '*.sph' | grep '$set' > $tmp_dir/sph.list")
!= 0) {
die "Error getting list of sph files";
}
$tmp_dir = "$out_base_dir/tmp";
open(WAVLIST, "<", "$tmp_dir/sph.list") or die "cannot open wav list";
%wav = ();
while($sph = <WAVLIST>) {
chomp($sph);
@A = split("/", $sph);
$basename = $A[$#A];
$raw_basename = $basename;
$raw_basename =~ s/\.sph$// || die "bad basename $basename";
$wav{$raw_basename} = $sph;
}
close(WAVLIST) || die;
$out_dir = $out_base_dir . "/" . $ldc_code . '_' . $set;
if (system("mkdir -p $out_dir") != 0) {
die "Error making directory $out_dir";
}
open(WAV, ">$out_dir" . '/wav.scp')
|| die "Failed opening output file $out_dir/wav.scp";
open(UTT2LANG, ">$out_dir" . '/utt2lang')
|| die "Failed opening output file $out_dir/utt2lang";
open(UTT2SPK, ">$out_dir" . '/utt2spk')
|| die "Failed opening output file $out_dir/utt2spk";
foreach $recording (sort keys(%wav)) {
foreach $channel ( (1, 2) ) {
$uttId = $ldc_code . "_" . $recording . "_" . $channel;
print WAV "$uttId"," sph2pipe -f wav -p -c ${channel} $wav{$recording} |\n";
print UTT2SPK "$uttId $uttId\n";
print UTT2LANG "$uttId $lang\n";
}
}
close(WAV) || die;
close(UTT2SPK) || die;
close(UTT2LANG) || die;
#system("rm -r $out_base_dir/tmp");
system("utils/fix_data_dir.sh $out_dir");
(system("utils/validate_data_dir.sh --no-text --no-feats $out_dir") == 0)
|| die "Error validating data dir.";
}