-
Notifications
You must be signed in to change notification settings - Fork 0
/
modify_sample_rate.pl
executable file
·50 lines (33 loc) · 1.09 KB
/
modify_sample_rate.pl
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
#!/usr/bin/perl
# Modifies the default sample rate of 8000 to SAMPLE
$Pvfdeftooldir = '/usr/bin';
my $Sample = shift
|| die "$0 SAMPLE [PVFTOOLDIR]\nPlease enter a sample rate (e.g. 7200)";
my $Pvftooldir = shift || $Pvfdeftooldir;
unless (-x "$Pvftooldir/pvfspeed") {
print "Can't find pvfspeed executable, please add the pvftooldir as an
arg\n";
print "E.g. $0 7200 /usr/bin\n";
exit(0);
}
die "Invalid sample rate $Sample"
unless ($Sample =~ /^\d+$/);
die "Must run this from the top directory of the VOCP install"
unless (-e "./messages");
# change name of files
my $cmd = qq{find messages/ -name "*.pvf" | xargs -i mv {} {}.$Sample};
system($cmd);
my @soundfiles = `find messages/ -name "*.pvf.$Sample"`;
print "Converting sound files...\n";
foreach my $file (@soundfiles) {
unless ($file =~ /^([^.]+)\.(pvf\.[\w\d]+)$/) {
print STDERR "Invalid filename $file\n";
next;
}
my $base = $1;
my $ext = $2;
system("/bin/cat $base.$ext | $Pvftooldir/pvfspeed -s $Sample > $base.pvf");
system("/bin/rm $file");
}
print "PVF files converted from 8000 to $Sample sample rate\n";
exit(0);