#!/usr/bin/perl # FORM1 2 Praat # # This scripts takes a .form1 file as an arugment # and converts it to the .praat file format for display # in the Praat speech analysis tool. # # Chris Osborn # cosborn@ldc.upenn.edu # # FORM Project, Linguistic Data Consortium # University of Pennsylvania # # http://www.ldc.upenn.edu/Projects/FORM/ # foreach $file (@ARGV){ $columns = 3; $rows = 0; $outFile = $file; $outFile =~ s/.form1/.praat/g; open(FILE, "./$file"); open(OUT, ">./$outFile"); while(){ if($_ =~ /^#.*?\.form1/){($newName) = ($_ =~ /^#(.*?)\.form1/);} if($_ =~ /Right/){$arm = 0;} elsif($_ =~ /Left/){$arm = 1;} if($_ =~ /^\d/){ ($frame, $lift, $orientation) = ($_ =~ /^(\d*?),(.*?),(.*?),/); if($arm == 0){ $lineHashRight{$frame}{"lift"} = $lift; $lineHashRight{$frame}{"orientation"} = $orientation; } else{ $lineHashLeft{$frame}{"lift"} = $lift; $lineHashLeft{$frame}{"orientation"} = $orientation; } $rows = $rows + 1; } } close(FILE); print OUT "\"$newName\"\n"; print OUT "\"TableOfReal\"\n"; print OUT "$columns \"Lift\" \"Orientation\"\n"; print OUT "$rows\n"; foreach $frame (sort {$a <=> $b} keys %lineHashRight){ $tempLift = $lineHashRight{$frame}{"lift"}; $tempOrientation = $lineHashRight{$frame}{"orientation"}; print OUT "\"$frame\" $tempLift $tempOrientation\n"; } close(OUT); }