Blame view
spkDiarization/scripts/SpkMoulinette.pl
1.45 KB
3f2992b2c V1.0 |
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
#!/usr/bin/perl # Perl program to convert .lbl file into .rttm ones # # Author: Xavier Bost # email: xavier.bost@univ-avignon.fr # # Synopsis: # # Source file: (arg1).lbl # # Retained informations are written in: # (arg2).rttm use strict; my $line; # current source file line my @fields; # current line fields my $file_in; my $file_out; my $speaker; my %start = (); my %end = (); my $base_name; my $i; my $dur; my $nArgs = scalar(@ARGV); # command line arguments number # die out if improper number of arguments ($nArgs == 2) or die "Error: two arguments expected (input file, output file). "; $file_in = shift(@ARGV); $file_out = shift(@ARGV); if ($file_in =~ /.*\/(.+)\.lbl/) { $base_name = $1; } open(IN, $file_in); # parsing input file while ($line = <IN>) { chomp($line); @fields = split(/\ /, $line); $speaker = $fields[2]; $start{$speaker}{$i} = $fields[0]; $end{$speaker}{$i} = $fields[1]; $i++; } close(IN); open(OUT, "> $file_out"); # writing out data for $speaker (sort keys %start) { print OUT "SPKR-INFO ".$base_name." 1 <NA> <NA> <NA> unknown ".$speaker." <NA> "; } foreach $speaker (sort keys %start) { foreach $i (sort {$start{$speaker}{$a}<=>$start{$speaker}{$b}} keys %{$start{$speaker}}) { $dur = $end{$speaker}{$i} - $start{$speaker}{$i}; printf OUT ("SPEAKER %s 1 %.2f %.2f <NA> <NA> %s <NA> ", $base_name, $start{$speaker}{$i}, $dur, $speaker); } } close(OUT); |