Changeset 2572
- Timestamp:
- 05/07/08 23:12:58 (8 months ago)
- Files:
-
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook.pm (modified) (2 diffs)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/Audio.pm (modified) (9 diffs)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/Dictionary.pm (modified) (3 diffs)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/Text.pm (modified) (2 diffs)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/input_files/htk/models (added)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/input_files/htk/models/hmmdefs (moved) (moved from Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/input_files/htk/hmmdefs)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/input_files/htk/models/macros (moved) (moved from Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/input_files/htk/macros)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/input_files/htk/models/tiedlist (moved) (moved from Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/input_files/htk/tiedlist)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/input_files/htk/train.scp (modified) (1 diff)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/interim_files/dlog (modified) (1 diff)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/interim_files/train.scp (deleted)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/interim_files/wav/prompts (deleted)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/interim_files/words.mlf (modified) (1 diff)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/output_files (added)
- Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/output_files/wav (moved) (moved from Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/interim_files/wav)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook.pm
r2565 r2572 34 34 use AudioBook::Dictionary; 35 35 #################################################################### 36 ### Options 37 #################################################################### 36 38 our($opt_a, $opt_t,$opt_d,$opt_T); # need to define these because using strict. 37 39 getopt('atdt'); # sets $opt_* as a side effect. … … 51 53 print "testfile:$textfile\n"; 52 54 print "voxforgeDict:$voxforgeDict\n"; 55 #################################################################### 56 ### Class Variables 57 #################################################################### 53 58 my $command; 59 my %parms; 60 $parms{'debug'} = 0; 61 $parms{'g2p_model'} = "AudioBook/input_files/g2p/models/model-5"; 62 $parms{'htk_files'} = "AudioBook/input_files/htk"; 63 54 64 #################################################################### 55 65 ### Main 56 66 #################################################################### 57 my $textContents = AudioBook::Text->new( $textfile);58 $textContents->createWLISTFile(" interim_files/wlist");59 my $dictionary = AudioBook::Dictionary->new( $voxforgeDict);60 my $missingwordfound = $dictionary->findOutOfVocabularyWords(" interim_files/MissingWords");67 my $textContents = AudioBook::Text->new(\%parms,$textfile); 68 $textContents->createWLISTFile("AudioBook/interim_files/wlist"); 69 my $dictionary = AudioBook::Dictionary->new(\%parms,$voxforgeDict); 70 my $missingwordfound = $dictionary->findOutOfVocabularyWords("AudioBook/interim_files/MissingWords"); 61 71 if ($missingwordfound) { 62 $dictionary->getPronunciations(" interim_files/MissingWords_out"); # uses g2p72 $dictionary->getPronunciations("AudioBook/interim_files/MissingWords_out"); # uses g2p 63 73 $dictionary->updatePronDict(); 64 74 # need to update dict with missing words 65 $command = ("HDMan -A -D -T 1 -g htk/global.ded -m -w interim_files/wlist -i -l interim_files/dlog interim_files/dict $voxforgeDict"); system($command) == 0 or confess "fullrun $command failed: $?"; 75 my $htk_files = $parms{'htk_files'}; 76 $command = ("HDMan -A -D -T 1 -g $htk_files/global.ded -m -w AudioBook/interim_files/wlist -i -l AudioBook/interim_files/dlog AudioBook/interim_files/dict $voxforgeDict"); system($command) == 0 or confess "fullrun $command failed: $?"; 66 77 } 67 #$command = ("perl fullrun/htksegment.pl interim_files/$file_name $samplingRate"); print "$command\n"; system($command) == 0 or confess "fullrun $command failed: $?"; 68 my $audio = AudioBook::Audio->new($audiofile,$textContents); 78 my $audio = AudioBook::Audio->new(\%parms,$audiofile,$textContents); 69 79 $audio->segment(); 70 80 print "completed!\n"; Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/Audio.pm
r2570 r2572 51 51 #################################################################### 52 52 sub new { 53 my ($class,$ audiofile,$textContents) = @_;53 my ($class,$parms,$audiofile,$textContents) = @_; 54 54 print "Audio\.pm:audiofile:$audiofile\n"; 55 $command = ("rm -f interim_files/wav/*.wav"); print "$command\n"; system($command) == 0 or confess "Audio.pm $command failed: $?";55 $command = ("rm -f AudioBook/output_files/wav/*.wav"); print "$command\n"; system($command) == 0 or confess "Audio.pm $command failed: $?"; 56 56 57 57 my %self; 58 $self{" debug"} = 0;58 $self{"parms"} = $parms; 59 59 $self{"process_audio"} = 1; 60 60 $self{"filename"} = $audiofile; … … 84 84 my ($self,$textContents) = @_; 85 85 my $filename = $self->{"filename"}; 86 my $htk_files = $self->{'parms'}->{'htk_files'}; 86 87 87 88 # Hvite only works with 16kHz sampling rate audio 88 $command = ("sox $filename -c 1 -r 16000 -w interim_files/downsampled.wav"); print "$command\n"; system($command) == 0 or confess "fullrun $command failed: $?";89 $command = ("sox $filename -c 1 -r 16000 -w AudioBook/interim_files/downsampled.wav"); print "$command\n"; system($command) == 0 or confess "fullrun $command failed: $?"; 89 90 # create mlf file 90 $textContents->createMLFFile("downsampled"," interim_files/words.mlf" );91 $textContents->createMLFFile("downsampled","AudioBook/interim_files/words.mlf" ); 91 92 # forced alignment - creates aligned.out 92 $command = ("cd interim_files && HVite -A -D -T 1 -l '*' -a -b SENT-END -m -C ../htk/wav_config -H ../htk/macros -H ../htk/hmmdefs -m -t 250.0 150.0 1000.0 -I words.mlf -i aligned.out -S ../htk/train.scp dict ../htk/tiedlist"); system($command) == 0 or confess "error: $command failed: $?"; 93 #!!!!!! $command = ("cd AudioBook/interim_files && HVite -A -D -T 1 -l '*' -a -b SENT-END -m -C wav_config -H macros -H hmmdefs -m -t 250.0 150.0 1000.0 -I words.mlf -i aligned.out -S train.scp dict tiedlist"); system($command) == 0 or confess "error: $command failed: $?"; 94 $command = ("pwd && HVite -A -D -T 1 -l '*' -a -b SENT-END -m -C $htk_files/wav_config -H $htk_files/models/macros -H $htk_files/models/hmmdefs -m -t 250.0 150.0 1000.0 -I AudioBook/interim_files/words.mlf -i AudioBook/interim_files/aligned.out -S $htk_files/train.scp AudioBook/interim_files/dict $htk_files/models/tiedlist"); system($command) == 0 or confess "error: $command failed: $?"; 95 93 96 } 94 97 95 98 sub _processHViteOutput { # private 96 99 my ($self) = @_; 97 98 open(ALIGNED, "< interim_files/aligned.out") or confess ("can\'t openinterim_files/aligned.out file for reading");100 101 open(ALIGNED, "<AudioBook/interim_files/aligned.out") or confess ("can\'t open AudioBook/interim_files/aligned.out file for reading"); 99 102 my @aligned = <ALIGNED>; 100 103 close ALIGNED; … … 123 126 } 124 127 } 125 open(LOG, "> interim_files/htksegment_log") or confess ("cannot open htksegment_log for output");128 open(LOG, ">AudioBook/interim_files/htksegment_log") or confess ("cannot open htksegment_log for output"); 126 129 foreach my $line (@aligned_words) { 127 130 print LOG "$line\n"; … … 142 145 print "### segment::$filename #################################################################\n"; 143 146 # copy to "interim_files"" directory for processing; also converts to 16 bits per sample (-w=16-bits) so it can be processed by HVite 144 $command = ("sox $filename -w interim_files/$filename_nopath"); print "$command\n"; system($command) == 0 or confess "fullrun $command failed: $?";147 $command = ("sox $filename -w AudioBook/interim_files/$filename_nopath"); print "$command\n"; system($command) == 0 or confess "fullrun $command failed: $?"; 145 148 146 149 my $loop; … … 154 157 my @aligned_line = split(/ /,$$aligned_words[$sentence_end]); 155 158 my ($word,$startTime,$endTime,$pause) = @aligned_line; 156 open(PROMPTS, "> interim_files/wav/prompts") or confess ("cannot open interim_files/wav/prompts for output");159 open(PROMPTS, ">AudioBook/output_files/prompts") or confess ("cannot open AudioBook/output_files/prompts for output"); 157 160 while (!$lastSentence) { 158 161 $loop++; … … 187 190 } 188 191 189 $command = ("rm interim_files/wav/temp.wav"); print "cmd:$command\n" if $debug; system($command);192 $command = ("rm AudioBook/interim_files/wav/temp.wav"); print "cmd:$command\n" if $debug; system($command); 190 193 print "### segment summary: #################################################################\n"; 191 194 print "\nSentence Length: min:$min_sentence_length_linenumber->$min_sentence_length_found; max:$max_sentence_length_linenumber->$max_sentence_length_found\n"; … … 194 197 print "\t$line\n"; 195 198 } 199 $command = ("mv AudioBook/interim_files/dict AudioBook/output_files"); print "cmd:$command\n" if $debug; system($command); 200 $command = ("mv AudioBook/interim_files/MissingWords_out AudioBook/output_files/MissingWords_pron"); print "cmd:$command\n" if $debug; system($command); 196 201 } 197 202 … … 323 328 my $filename_nosuffix = $self->{"filename_nosuffix"}; 324 329 my $filename_nopath = $self->{"filename_nopath"}; 330 my $htk_files = $self->{'parms'}->{'htk_files'}; 325 331 326 332 #print "debug:$debug;process_audio:$process_audio:\n"; … … 330 336 # use TARGETKIND=NOHEAD in HCopy command to remove 'click' noise that HCopy puts at the very beginning of each file it creates 331 337 # make sure you use NATURALWRITEORDER = T and NATURALREADORDER = T in the HTK config file 332 $command = ("HCopy -C htk/copy_config -s $startTime -e $endTime interim_files/$filename_nopath interim_files/wav/temp.wav"); print "cmd:$command\n" if $debug; system($command);338 $command = ("HCopy -C $htk_files/copy_config -s $startTime -e $endTime AudioBook/interim_files/$filename_nopath AudioBook/interim_files/temp.wav"); print "cmd:$command\n" if $debug; system($command); 333 339 # sox command to create a proper wav file with a RIFF header; 334 $command = ("sox -t .raw -r $samplerate -sw interim_files/wav/temp.wav interim_files/wav/$filename_nosuffix$padded_fileid.wav"); print "cmd:$command\n" if $debug; system($command);335 print " interim_files/wav/$filename_nosuffix$padded_fileid.wav\n" if not $debug;340 $command = ("sox -t .raw -r $samplerate -sw AudioBook/interim_files/temp.wav AudioBook/output_files/wav/$filename_nosuffix$padded_fileid.wav"); print "cmd:$command\n" if $debug; system($command); 341 print "AudioBook/output_files/wav/$filename_nosuffix$padded_fileid.wav\n" if not $debug; 336 342 } else { 337 print " interim_files/wav/$filename_nosuffix$padded_fileid.wav\t$startTime:$endTime:\n" if $debug;343 print "AudioBook/output_files/wav/$filename_nosuffix$padded_fileid.wav\t$startTime:$endTime:\n" if $debug; 338 344 } 339 345 } Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/Dictionary.pm
r2564 r2572 32 32 #################################################################### 33 33 sub new { 34 my ($class,$ voxforgeDict) = @_;34 my ($class,$parms,$voxforgeDict) = @_; 35 35 my %self; 36 $self{"parms"} = $parms; 36 37 $self{"voxforgeDict"} = $voxforgeDict; 37 38 bless(\%self,$class); … … 44 45 my ($self,$missing_words)= @_; 45 46 my $voxforgeDict = $self->{"voxforgeDict"}; 47 my $htk_files = $self->{'parms'}->{'htk_files'}; 48 46 49 $self->{"missing_words"} = $missing_words; 47 48 $command = ("HDMan -A -D -T 1 -g htk/global.ded -m -w interim_files/wlist -i -l interim_files/dloginterim_files/dict $voxforgeDict"); system($command) == 0 or confess "fullrun $command failed: $?";49 open(DLOG," interim_files/dlog") or confess ("cannot openinterim_files/dlog file");50 51 $command = ("HDMan -A -D -T 1 -g $htk_files/global.ded -m -w AudioBook/interim_files/wlist -i -l AudioBook/interim_files/dlog AudioBook/interim_files/dict $voxforgeDict"); system($command) == 0 or confess "fullrun $command failed: $?"; 52 open(DLOG,"AudioBook/interim_files/dlog") or confess ("cannot open AudioBook/interim_files/dlog file"); 50 53 open(MISSINGWORDS,">$missing_words") or confess ("cannot open $missing_words file"); 51 54 my $missingwordsheader = 0; … … 76 79 my ($self,$missing_words_out)= @_; 77 80 $self->{"missing_words_out"} = $missing_words_out; 81 my $model = $self->{'parms'}->{'g2p_model'}; 78 82 my $missing_words = $self->{"missing_words"}; 79 83 80 84 my @missingwords = `export PYTHONPATH=/usr/local/lib64/python2.4/site-packages && 81 g2p.py --model g2p/models/model-5--apply $missing_words`;85 g2p.py --model $model --apply $missing_words`; 82 86 if ($?) { 83 87 confess "g2p.py $command failed: $?"; Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/Text.pm
r2568 r2572 31 31 #################################################################### 32 32 sub new { 33 my ($class,$ inputfilename) = @_;33 my ($class,$parms,$inputfilename) = @_; 34 34 my %self; 35 $self{"parms"} = $parms; 35 36 $self{"inputfilename"} = $inputfilename; 36 37 _clean(\%self); … … 118 119 open(MLF, ">$MLFFile") or confess ("cannot open words.mlf for output"); 119 120 print MLF "#!MLF!#\n"; # 120 print MLF "\" $wavfilename.lab\"\n";121 print MLF "\"AudioBook/interim_files/$wavfilename.lab\"\n"; 121 122 foreach my $word (@$words) { 122 123 print MLF "$word\n"; Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/input_files/htk/train.scp
r2553 r2572 1 downsampled.wav1 AudioBook/interim_files/downsampled.wav Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/interim_files/dlog
r2570 r2572 55 55 43. th : 1 56 56 57 Dictionary interim_files/dict created57 Dictionary AudioBook/interim_files/dict created Trunk/Scripts/Audio_scripts/AudioSegmentation/AudioBook/interim_files/words.mlf
r2570 r2572 1 1 #!MLF!# 2 " downsampled.lab"2 "AudioBook/interim_files/downsampled.lab" 3 3 THOSE 4 4 EVENING