voxforge.org
VoxForge Dev

root/Trunk/Scripts/Audio_scripts/AudioSegmentation/htklabels2audacity.pl

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

Flac audio processing updates & GPL v3 updates

Line 
1 #! /usr/bin/perl
2 ####################################################################
3 ###
4 ### script name : htklabels2audacity.pl
5 ### version: 0.1
6 ### created by: Ken MacLean
7 ### mail: contact@voxforge.org
8 ### Date: 2007.03.12
9 ### Command: perl ./htklabels2audacity.pl [infile-HTKlabels] [outfile-AudacityLabels]
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
25 if ($#ARGV != 1) {
26  print "usage: inputfilename outputfilename\n";
27  exit;
28 }
29 $inputfilename = $ARGV[0];
30 $outputfilename = $ARGV[1];
31 open(IN, "<$inputfilename") or die ("need input file name");
32 open(OUT, ">$outputfilename") or die ("need output file name");
33
34 my @lines = <IN>;   
35
36 foreach my $line (@lines)    {
37         chomp $line;
38         my @labels = split(/ /, $line);
39         my $startTime = shift @labels;
40         my $audacity_startTime = (($startTime /10 ) / 1000000);
41         my $endTime = shift @labels;   
42         my $phone = shift @labels;     
43         my $score = shift @labels;     
44         my $word = shift @labels;       
45 #print OUT "$startTime $endTime $phone $score $word\n";
46         if ($word ne "") {
47             print OUT "$audacity_startTime $word\n";
48         }               
49 }
50 close(IN);
51 close(OUT);
Note: See TracBrowser for help on using the browser.