use strict;
opendir(DIR, "./") or die $!; # open current directory
my @files;
while (my $file = readdir(DIR)) {
# Use a regular expression to ignore files beginning with a period
push(@files, lc($file));
}
closedir(DIR);
# read the prompt.
my $promptfile = shift;
print STDERR "reading $promptfile\n";
open(PROMPT, $promptfile);
my $i = 0;
while (my $prompt = <PROMPT>) {
$i++;
print STDERR $prompt . "\n";
$prompt =~ s/^\d+\.\s//; # remove "93. ";
$prompt = lc($prompt);
# concat a list of .wav files corresponding to the prompt
my $files = "";
foreach my $word (split(/\s+/, $prompt)) {
# choose a random file from the files, that beings with the gi
+ven $word.
my @grepped = grep(/^$word/, @files);
my $file = $grepped[ int(rand(scalar @grepped)) ]; # choose a
+random file
$files .= $file . " ";
}
my $output = sprintf("S%05d",$i);
my $command = "sox $files $output.wav";
print STDERR $command . "\n"; # TODO: add system call.
system($command);
print STDOUT "$output.wav $output.mfc\n";
}
close(PROMPT);
AFTER RUN THIS I GOT
Use of uninitialized value $file in concatenation (.) or string at scr
+ipts/conca
tprompt.pl line 29, <PROMPT> line 100.
sox S00100.wav
sox FAIL sox: Not enough input filenames specified
AND COMMAND IS LIKE:
perl -w scripts/concatprompt.pl trainprompts > codetrain.scp
PLEASE TELL ME HOW TO REMOVE THIS ERROR...