summaryrefslogtreecommitdiff
path: root/tools/voice.pl
diff options
context:
space:
mode:
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);