voxforge.org
VoxForge Dev
Show
Ignore:
Timestamp:
05/25/08 20:14:38 (6 months ago)
Author:
kmaclean
Message:

AudioSegmentation scripts -snapshot

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook.pm

    r2589 r2590  
    3030use Getopt::Std; 
    3131use File::Basename; 
     32use File::Copy; 
    3233use lib '/home/kmaclean/VoxForge-dev/Main/Scripts/Audio_scripts/AudioSegmentation'; 
    3334use AudioBook::Audio; 
     
    3738### Class Variables 
    3839#################################################################### 
    39 our($opt_a,$opt_d,$opt_h,$opt_l,$opt_m,$opt_p,$opt_r,$opt_s,$opt_t,$opt_x,$opt_S,$opt_T,$opt_u); # need to define these because using strict. 
     40our($opt_a,$opt_b,$opt_d,$opt_h,$opt_l,$opt_m,$opt_p,$opt_r,$opt_s,$opt_t,$opt_x,$opt_q,$opt_S,$opt_T,$opt_u); # need to define these because using strict. 
    4041my %self; 
    4142$self{'debug'} = 0; 
     
    8586        } else { 
    8687                open(LOG,">>$log") or confess ("cannot open AudioBook/output_files/MissingWords file"); 
    87                 print LOG "\nMissing Words added to Pronunciation Dictionary:\n";      
     88                print LOG "\nMissing Words that need to be added to Pronunciation Dictionary, with suggested pronunciations::\n";      
    8889                print LOG "------------------------------------------------\n";                          
    8990                print LOG "no missing words\n"; 
     
    9394        my $audio = AudioBook::Audio->new($self); 
    9495        $audio->segment($audiofile,$textContents); 
     96        $audio->verifySegments;  
    9597        if (defined($tarSuffix)){ 
    9698                _createTarFile($self); 
     
    106108                unlink (<AudioBook/interim_files/logs/*>);       
    107109        } 
     110        if (defined(<AudioBook/interim_files/wav/*>)) { 
     111                unlink (<AudioBook/interim_files/wav/*>);        
     112        }        
    108113        if (defined(<AudioBook/output_files/wav/*>)) { 
    109114                unlink (<AudioBook/output_files/wav/*>);         
     
    127132        $mday = sprintf("%02d", $mday); 
    128133        print "creating gzipped tar file:$username\-$year$mon$mday\-$tarSuffix\.tgz \n"; 
    129         $command = ("cp $readme AudioBook/output_files/README"); print "cmd:$command\n" if $debug; system($command);     
    130         $command = ("cp $license AudioBook/output_files/LICENSE"); print "cmd:$command\n" if $debug; system($command);   
     134        # !!!!!! 
     135        #$command = ("cp $readme AudioBook/output_files/README"); print "cmd:$command\n" if $debug; system($command); 
     136        if (defined($readme)) { 
     137                copy("$readme","AudioBook/output_files/README"); 
     138        } else { 
     139                print "Warning: no README file to copy\n"; 
     140        } 
     141        #$command = ("cp $license AudioBook/output_files/LICENSE"); print "cmd:$command\n" if $debug; system($command);          
     142        if (defined($license)) { 
     143                copy("$license","AudioBook/output_files/LICENSE"); 
     144        } else { 
     145                print "Warning: no LICENSE file to copy\n"; 
     146        } 
     147        $command = ("cp AudioBook/interim_files/wav/* AudioBook/output_files/wav/"); print "cmd:$command\n" if $debug; system($command);         
     148        # !!!!!!         
    131149        if ($debug) { 
    132150                $command = ("tar -zcvf $username\-$year$mon$mday\-$tarSuffix\.tgz AudioBook/output_files --exclude \"\.svn\" "); print "cmd:$command\n" if $debug; system($command); 
     
    150168        my ($self)= @_; 
    151169        my $debug = $self->{'debug'};    
    152         getopts('a:d:hl:m:p:r:s:t:u:x:ST');    #  sets $opt_* as a side effect. 
     170        getopts('a:b:d:hl:m:p:r:s:t:u:x:q:ST');    #  sets $opt_* as a side effect. 
    153171        if ($opt_a and $opt_t) {         
    154172                if (-r $opt_a) { 
     
    186204                } else { 
    187205                        $self->{"min_pause_for_sentence_break"}= $default_min_pause_for_sentence_break;  
    188                 }                
     206                }        
     207                if ($opt_q) { 
     208                        if (($opt_q eq "no") or ($opt_q eq "No") or ($opt_q eq "NO")){ 
     209                                $self->{"log_single_quotes"}= 0; 
     210                        } else { 
     211                                $self->{"log_single_quotes"}= 1;         
     212                        } 
     213                } else { 
     214                        $self->{"log_single_quotes"}= "yes";     
     215                }        
     216                if ($opt_b) { 
     217                        $self->{"beam_width"}=$opt_b; 
     218                } else { 
     219                        $self->{"beam_width"}=250;       
     220                } 
    189221                ### Tar file processing 
    190222                if (defined($opt_T)) { 
     
    233265                print   "=============================================\n";       
    234266                print "-a\t* audio file name (WAV format only)\n"; 
     267                print "-b\tbeam width for Forced Alignment with HVit (default = 250)\n"; 
    235268                print "-d\tpronunciation dictionary  (default = AudioBook/input_files/VoxforgeDict)\n"; 
    236269                print "-h\tshow help\n";         
     
    238271                print "-m\tMaximum sentence length (default = $default_max_sentence_length words)\n"; 
    239272                print "-p\tMinimum pause for sentence break (default = $default_min_pause_for_sentence_break in units of 100ns)\n";              
    240                 print "-r\tREADME file (default = AudioBook/input_files/README)\n";              
     273                print "-q\tlog words with single quotes (default = yes)\n";              
     274                print "-r\tREADME file (default = AudioBook/input_files/README)\n";                              
    241275                print "-s\tAverage sentence length (default = $default_average_sentence_length words)\n";                                
    242276                print "-t\t* text file name\n";