summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-07-10 19:13:51 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-07-10 23:28:25 +0000
commit711bff47b74641c888de59c269ed76e99f16a239 (patch)
treeb886669275302b8b662ad5ad48256e99eff47a1c /tools
parentc914b148e5137c60561028e09859e2747ff6f3ad (diff)
downloadrockbox-711bff47b74641c888de59c269ed76e99f16a239.tar.gz
rockbox-711bff47b74641c888de59c269ed76e99f16a239.tar.bz2
rockbox-711bff47b74641c888de59c269ed76e99f16a239.zip
voice: Enhance 'espeak' to automatically pick the language + voice
Most of the 'perfect' or 'good' translations are covered. Also, don't override user-specified voice Change-Id: I837bd67e9df2b8bcc7e020f12a2f411c9175565b
Diffstat (limited to 'tools')
-rwxr-xr-xtools/voice.pl31
1 files changed, 24 insertions, 7 deletions
diff --git a/tools/voice.pl b/tools/voice.pl
index e7e1346886..edb2c9f233 100755
--- a/tools/voice.pl
+++ b/tools/voice.pl
@@ -91,6 +91,20 @@ my %gtts_lang_map = (
'srpski' => 'sr',
);
+my %espeak_lang_map = (
+ 'english' => 'en-gb', # Always first, it's the golden master
+ 'deutsch' => 'de',
+ 'english-us' => 'en-us',
+ 'francais' => 'fr-fr',
+# 'greek' => 'gr',
+ 'italiano' => 'it',
+ 'norsk' => 'no',
+ 'polski' => 'pl',
+ 'russian' => 'ru',
+ 'slovak' => 'sk',
+ 'srpski' => 'sr',
+);
+
# Initialize TTS engine. May return an object or value which will be passed
# to voicestring and shutdown_tts
sub init_tts {
@@ -108,8 +122,8 @@ sub init_tts {
$SIG{INT} = sub { kill TERM => $pid; print("foo"); panic_cleanup(); };
$SIG{KILL} = sub { kill TERM => $pid; print("boo"); panic_cleanup(); };
$ret{"pid"} = $pid;
- if (defined($festival_lang_map{$language})) {
- $ret{"ttsoptions"} = "-l $festival_lang_map{$language} ";
+ if (defined($festival_lang_map{$language}) && $tts_engine_opts !~ /--language/) {
+ $ret{"ttsoptions"} = "--language $festival_lang_map{$language} ";
}
} elsif ($tts_engine eq 'sapi') {
my $toolsdir = dirname($0);
@@ -133,10 +147,15 @@ sub init_tts {
"vendor" => $vendor);
} elsif ($tts_engine eq 'gtts') {
$ret{"format"} = 'mp3';
- if (defined($gtts_lang_map{$language})) {
+ if (defined($gtts_lang_map{$language}) && $tts_engine_opts !~ /-l/) {
$ret{"ttsoptions"} = "-l $gtts_lang_map{$language} ";
}
+ } elsif ($tts_engine eq 'espeak') {
+ if (defined($espeak_lang_map{$language}) && $tts_engine_opts !~ /-v/) {
+ $ret{"ttsoptions"} = "-v$gtts_lang_map{$language} ";
+ }
}
+
return \%ret;
}
@@ -207,11 +226,9 @@ sub voicestring {
system($cmd);
}
elsif ($name eq 'espeak') {
- $cmd = "espeak $tts_engine_opts -w \"$output\"";
+ $cmd = "espeak $tts_engine_opts -w \"$output\" \"$string\"";
print("> $cmd\n") if $verbose;
- open(ESPEAK, "| $cmd");
- print ESPEAK $string . "\n";
- close(ESPEAK);
+ system($cmd);
}
elsif ($name eq 'sapi') {
print({$$tts_object{"stdin"}} "SPEAK\t$output\t$string\r\n");