voxforge.org
VoxForge Dev

root/Trunk/Scripts/Testing_scripts/mp3_testing/Test_mp3.pm

Revision 2270, 5.3 kB (checked in by kmaclean, 1 year ago)

Flac audio processing updates & GPL v3 updates

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl -w
2 ####################################################################
3 ###
4 ### script name: Test_mp3.pm
5 ### modified by: Ken MacLean
6 ### email: contact@voxforge.org
7 ### Date: 2007.03.08
8 ### Command: ./Test_mp3.pm
9 ### Version: 0.1
10 ###             
11 ### Copyright (C) 2007 Ken MacLean
12 ###
13 ### This program is free software; you can redistribute it and/or
14 ### modify it under the terms of the GNU General Public License
15 ### as published by the Free Software Foundation; either version 3
16 ### of the License, or (at your option) any later version.
17 ###
18 ### This program is distributed in the hope that it will be useful,
19 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ### GNU General Public License for more details.
22 ###
23 ####################################################################
24 package Test_mp3;
25 use strict;
26 use File::Spec;
27 use POSIX qw(strftime);
28 ####################################################################
29 #  parms
30 my (%parms, $command);
31 $parms{"debug"} = 1;
32 $parms{"AudioDirectory"} = "/home/kmaclean/workspace/VoxForge/Audio/Temp/16kHz_16bit";
33         $parms{"wav2-MFCC_0_D"}  =      $parms{"AudioDirectory"} . "/wav2-MFCC_0_D";   
34         $parms{"wav-MFCC_0_D"}  =       $parms{"AudioDirectory"} . "/wav-MFCC_0_D";     
35 $parms{"Nightly_test_dir"} = "/home/kmaclean/workspace/VoxForge/Scripts/Testing_scripts/Nightly_test"
36 $parms{"LexiconDirectory"} = "/home/kmaclean/workspace/VoxForge/Lexicon";       
37 $parms{"HTKBin"}  = "/usr/local/HTK" ;
38 $parms{"JulianBin"}  = "/home/kmaclean/bin/julius-3.5.2-multipath-linuxbin/bin" ;
39 ####################################################################
40 Process(\%parms);
41 print "Test_mp3.pm completed!\n";
42
43 sub Process {
44         my ($parameters ) = @_;
45                 my %parms = %$parameters;
46                 my $debug = $parms{"debug"};   
47                 my $HTKbin = $parms{"HTKBin"};
48                 my $Nightly_test_dir = $parms{"Nightly_test_dir"} ;     
49         $command = ("cd $Nightly_test_dir && perl $HTKbin/prompts2mlf testref.mlf testprompts"); print "$command\n" if $debug; system($command);   
50         process16kHz_16bit(\%parms) || die "Nightly_test error: $?";
51
52         return 1;   
53 }
54 ####################################################################
55 ### Subroutines
56 ####################################################################
57 sub process16kHz_16bit {
58         my ($parameters ) = @_;
59         my %parms = %$parameters;
60                 my $debug = $parms{"debug"};
61                 my $Nightly_dirname = $parms{"Nightly_dirname"};
62                 my $AM_Dir = "/home/kmaclean/workspace/VoxForge/Audio/Temp/16kHz_16bit/wav-MFCC_0_D/acoustic_model_files";
63         open(OUTPUT, ">TestResults") or die ("cannot write to TestResults file"); # open for output                     
64         HTK_16kHz_16bit(\%parms, $AM_Dir) || die "Nightly_test error: $?";
65         Julian_16kHz_16bit(\%parms, $AM_Dir) || die "Nightly_test error: $?";
66         return 1;   
67 }
68
69 sub HTK_16kHz_16bit {
70         my ($parameters, $AM_Dir ) = @_;
71                 my %parms = %$parameters;       
72                 my $debug = $parms{"debug"};
73                 my $LexiconDirectory = $parms{"LexiconDirectory"};
74                 my $HTKbin = $parms{"HTKBin"} ;
75                 my $Nightly_test_dir = $parms{"Nightly_test_dir"};     
76         my $wordinspen = "0.0";
77         my $gramscfact = "1.0";
78         system("rm -f recout.mlf");
79         $command = ("cd $Nightly_test_dir && $HTKbin/HVite -A -D -T 1 -H $AM_Dir/macros -H $AM_Dir/hmmdefs -C $Nightly_test_dir/wav_config -S $Nightly_test_dir/test_wavlst16kHz_16bit -l '*' -i recout.mlf -w $Nightly_test_dir/wdnet -p $wordinspen -s $gramscfact $LexiconDirectory/VoxForge/VoxForgeDict $AM_Dir/tiedlist  1>/dev/null 2>/dev/null");  system($command); 
80         my $HTK_TestResults = `cd $Nightly_test_dir &&  $HTKbin/HResults -I testref.mlf $AM_Dir/tiedlist recout.mlf`;
81         $HTK_TestResults =~ s/ HTK//;
82         print OUTPUT ("HTK 16kHz_16bit\n");   
83         print OUTPUT ("---------------\n");   
84         print OUTPUT ("  Parameters:\n");               
85         print OUTPUT ("\tword insertion penalty: $wordinspen\n");
86         print OUTPUT ("\tgrammar scale factor: $gramscfact\n");         
87         print OUTPUT "$HTK_TestResults\n";
88         return 1;       
89 }
90
91 sub Julian_16kHz_16bit {       
92         my ($parameters, $AM_Dir ) = @_;
93                 my %parms = %$parameters;       
94                 my $debug = $parms{"debug"};           
95                 my $HTKbin = $parms{"HTKBin"} ;
96                 my $JulianBin = $parms{"JulianBin"};
97                 my $Nightly_test_dir = $parms{"Nightly_test_dir"};     
98         my $penalty1="0.5";
99         my $penalty2="100.0";
100         my $iwsppenalty = "-55.0";
101         system("rm -f julianProcessed");               
102         $command = ("cd $Nightly_test_dir &&  $JulianBin/julian -penalty1 $penalty1 -penalty2 $penalty2 -iwsppenalty $iwsppenalty -input rawfile -filelist test_wavlst16kHz_16bit -h $AM_Dir/hmmdefs -hlist $AM_Dir/tiedlist -smpFreq 16000  -C julian.jconf  > julianOutput 2>/dev/null"); print "$command\n" if $debug; system($command) ;
103         $command = ("cd $Nightly_test_dir &&  perl ./ProcessJulianOutput.pl julianOutput julianProcessed"); print "$command\n" if $debug; system($command) ;   
104         my $Julian_TestResults = `cd $Nightly_test_dir &&  $HTKbin/HResults -I testref.mlf $AM_Dir/tiedlist julianProcessed` ;
105         $Julian_TestResults =~ s/ HTK//;
106         print OUTPUT ("Julian 16kHz_16bit\n");
107         print OUTPUT ("------------------\n");           
108         print OUTPUT ("  Parameters:\n");       
109         print OUTPUT ("\tword insertion penalty\n"); 
110         print OUTPUT ("\t  first pass (-penalty1):$penalty1\n"); 
111         print OUTPUT ("\t  second pass (-penalty2):$penalty2\n"); 
112         print OUTPUT ("\ttransition penalty (-iwsppenalty):$iwsppenalty (for short-term inter-word pauses between words)\n");           
113         print OUTPUT "$Julian_TestResults\n";
114         return 1;       
115 }
116 1;
Note: See TracBrowser for help on using the browser.