summaryrefslogtreecommitdiff
path: root/tools/voice.pl
diff options
context:
space:
mode:
authorAlex Parker <rockbox@aeparker.com>2011-07-19 19:16:54 +0000
committerAlex Parker <rockbox@aeparker.com>2011-07-19 19:16:54 +0000
commit354d8fbc63f861401b402f96975a5ab3e27d1dff (patch)
tree05360e385908b29fd3f788c6db04a4ab1433059c /tools/voice.pl
parent31b7ecb09b31d7fb1e95758d5c7b3b40b38437ed (diff)
downloadrockbox-354d8fbc63f861401b402f96975a5ab3e27d1dff.tar.gz
rockbox-354d8fbc63f861401b402f96975a5ab3e27d1dff.zip
Commit FS#12188 - Fix perl scripts that used Switch by Sean Bartell.
Perl 5.14 removed Switch which means that Rockbox will no longer build with the current release of Perl. The patch replaces Switch with given/when which was introduced in Perl 5.10.0. Debian stable has 5.10.1, cygwin 1.7 has 5.10.1 and Mac OSX 10.6 comes with 5.10.0. I'm not sure what version older versions of OSX come with, but newer versions are apparently available from Macports. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30169 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/voice.pl')
-rwxr-xr-xtools/voice.pl26
1 files changed, 13 insertions, 13 deletions
diff --git a/tools/voice.pl b/tools/voice.pl
index ee68c30eb4..9c528299b9 100755
--- a/tools/voice.pl
+++ b/tools/voice.pl
@@ -17,9 +17,9 @@
17 17
18use strict; 18use strict;
19use warnings; 19use warnings;
20use feature 'switch';
20use File::Basename; 21use File::Basename;
21use File::Copy; 22use File::Copy;
22use Switch;
23use vars qw($V $C $t $l $e $E $s $S $i $v); 23use vars qw($V $C $t $l $e $E $s $S $i $v);
24use IPC::Open2; 24use IPC::Open2;
25use IPC::Open3; 25use IPC::Open3;
@@ -74,8 +74,8 @@ sub init_tts {
74 our $verbose; 74 our $verbose;
75 my ($tts_engine, $tts_engine_opts, $language) = @_; 75 my ($tts_engine, $tts_engine_opts, $language) = @_;
76 my %ret = ("name" => $tts_engine); 76 my %ret = ("name" => $tts_engine);
77 switch($tts_engine) { 77 given ($tts_engine) {
78 case "festival" { 78 when ("festival") {
79 print("> festival $tts_engine_opts --server\n") if $verbose; 79 print("> festival $tts_engine_opts --server\n") if $verbose;
80 my $pid = open(FESTIVAL_SERVER, "| festival $tts_engine_opts --server > /dev/null 2>&1"); 80 my $pid = open(FESTIVAL_SERVER, "| festival $tts_engine_opts --server > /dev/null 2>&1");
81 my $dummy = *FESTIVAL_SERVER; #suppress warning 81 my $dummy = *FESTIVAL_SERVER; #suppress warning
@@ -83,7 +83,7 @@ sub init_tts {
83 $SIG{KILL} = sub { kill TERM => $pid; print("boo"); panic_cleanup(); }; 83 $SIG{KILL} = sub { kill TERM => $pid; print("boo"); panic_cleanup(); };
84 $ret{"pid"} = $pid; 84 $ret{"pid"} = $pid;
85 } 85 }
86 case "sapi" { 86 when ("sapi") {
87 my $toolsdir = dirname($0); 87 my $toolsdir = dirname($0);
88 my $path = `cygpath $toolsdir -a -w`; 88 my $path = `cygpath $toolsdir -a -w`;
89 chomp($path); 89 chomp($path);
@@ -111,12 +111,12 @@ sub init_tts {
111# Shutdown TTS engine if necessary. 111# Shutdown TTS engine if necessary.
112sub shutdown_tts { 112sub shutdown_tts {
113 my ($tts_object) = @_; 113 my ($tts_object) = @_;
114 switch($$tts_object{"name"}) { 114 given ($$tts_object{"name"}) {
115 case "festival" { 115 when ("festival") {
116 # Send SIGTERM to festival server 116 # Send SIGTERM to festival server
117 kill TERM => $$tts_object{"pid"}; 117 kill TERM => $$tts_object{"pid"};
118 } 118 }
119 case "sapi" { 119 when ("sapi") {
120 print({$$tts_object{"stdin"}} "QUIT\r\n"); 120 print({$$tts_object{"stdin"}} "QUIT\r\n");
121 close($$tts_object{"stdin"}); 121 close($$tts_object{"stdin"});
122 } 122 }
@@ -147,8 +147,8 @@ sub voicestring {
147 my ($string, $output, $tts_engine_opts, $tts_object) = @_; 147 my ($string, $output, $tts_engine_opts, $tts_object) = @_;
148 my $cmd; 148 my $cmd;
149 printf("Generate \"%s\" with %s in file %s\n", $string, $$tts_object{"name"}, $output) if $verbose; 149 printf("Generate \"%s\" with %s in file %s\n", $string, $$tts_object{"name"}, $output) if $verbose;
150 switch($$tts_object{"name"}) { 150 given ($$tts_object{"name"}) {
151 case "festival" { 151 when ("festival") {
152 # festival_client lies to us, so we have to do awful soul-eating 152 # festival_client lies to us, so we have to do awful soul-eating
153 # work with IPC::open3() 153 # work with IPC::open3()
154 $cmd = "festival_client --server localhost --otype riff --ttw --output \"$output\""; 154 $cmd = "festival_client --server localhost --otype riff --ttw --output \"$output\"";
@@ -168,22 +168,22 @@ sub voicestring {
168 close(CMD_OUT); 168 close(CMD_OUT);
169 close(CMD_ERR); 169 close(CMD_ERR);
170 } 170 }
171 case "flite" { 171 when ("flite") {
172 $cmd = "flite $tts_engine_opts -t \"$string\" \"$output\""; 172 $cmd = "flite $tts_engine_opts -t \"$string\" \"$output\"";
173 print("> $cmd\n") if $verbose; 173 print("> $cmd\n") if $verbose;
174 `$cmd`; 174 `$cmd`;
175 } 175 }
176 case "espeak" { 176 when ("espeak") {
177 $cmd = "espeak $tts_engine_opts -w \"$output\""; 177 $cmd = "espeak $tts_engine_opts -w \"$output\"";
178 print("> $cmd\n") if $verbose; 178 print("> $cmd\n") if $verbose;
179 open(ESPEAK, "| $cmd"); 179 open(ESPEAK, "| $cmd");
180 print ESPEAK $string . "\n"; 180 print ESPEAK $string . "\n";
181 close(ESPEAK); 181 close(ESPEAK);
182 } 182 }
183 case "sapi" { 183 when ("sapi") {
184 print({$$tts_object{"stdin"}} "SPEAK\t$output\t$string\r\n"); 184 print({$$tts_object{"stdin"}} "SPEAK\t$output\t$string\r\n");
185 } 185 }
186 case "swift" { 186 when ("swift") {
187 $cmd = "swift $tts_engine_opts -o \"$output\" \"$string\""; 187 $cmd = "swift $tts_engine_opts -o \"$output\" \"$string\"";
188 print("> $cmd\n") if $verbose; 188 print("> $cmd\n") if $verbose;
189 system($cmd); 189 system($cmd);