script/festival.pl untested

filter: Statementstmt 0.0% 0 / 33 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 3 Podpod n/a totaltotal 0.0% 0 / 52 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/local/bin/perl -w
2 # -*- cperl -*-
3 # PODNAME: festival.pl
4 # ABSTRACT: script converting textfile named $1
5 # into file $2
6 # with engine:voice $3
7 # using festival
8 our $VERSION = '20261115.1249'; # VERSION
9  
10  
11 use v5.32;
12 use IO::File;
13 use IPC::Run;
14  
15 # Check arguments
16 die( "Usage: $0 <input_text_file> <output_audio_file> <voice>\n" )
17 unless( 3 == @ARGV );
18  
19 my ( $textfilename, $audiofilename, $voice ) = @ARGV;
20  
21 # determine format from audiofilename
22 my $format = $audiofilename;
23 $format =~ s/.+\.([^\.]+)/$1/;
24  
25 # Run festival, run!
26 my $command = [
27 "text2wave",
28 "-eval",
29 "(voice_$voice)",
30 "-o",
31 "$audiofilename.wav",
32 "$textfilename"
33 ];
34 my $out;
35 IPC::Run::run( $command,
36 '>', \$out );
37 die( "Error: could not start festival's 'text2wave'\n" ) if ( $? );
38  
39 foreach ( $format ) {
40 'mp3' and do {
41 $command = [ "lame",
42 "$audiofilename.wav",
43 "$audiofilename" ];
44 last;
45 };
46 'ogg' and do {
47 $command = [ "oggenc",
48 "-o",
49 "$audiofilename",
50 "$audiofilename.wav" ];
51 last;
52 };
53 die( "Error: could not guess audio format based on output audiofilename\n" );
54 }
55 IPC::Run::run( $command,
56 '>', \$out );
57 exit($?) if ($?);
58 unlink "$audiofilename.wav";
59 exit(0);
60  
61 __END__