diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2024-04-17 14:42:36 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2024-04-17 14:55:17 -0400 |
commit | c38aeb3fbc6b45e5a71af4506c79459ce9cb2121 (patch) | |
tree | 4f235c02b006e2fa633bb8ce29e87f0402c17df8 /tools/voice.pl | |
parent | ebd952da2f50f73afa30554b0a0ad1a4dc5c7c63 (diff) | |
download | rockbox-c38aeb3fbc6b45e5a71af4506c79459ce9cb2121.tar.gz rockbox-c38aeb3fbc6b45e5a71af4506c79459ce9cb2121.zip |
voice: add a 'make talkclips' target for voice builds.
This will use the configured tts engine and language to generate
the talk clips for a specified directory.
TALKDIR=/path/to/somehere make talkclips
TALKDIR=/path/to/somehere make talkclips-force
If 'TALKDIR' is not defined then it will error out gracefully.
Normally if a talkclip is present already it will not regenerate the file,
but 'make talkclip-force' will regenerate it anyway.
Change-Id: I62683f9e5ca395fd303ac6029096c20da1e96d01
Diffstat (limited to 'tools/voice.pl')
-rwxr-xr-x | tools/voice.pl | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tools/voice.pl b/tools/voice.pl index 08f6bad509..2cb7867eb2 100755 --- a/tools/voice.pl +++ b/tools/voice.pl | |||
@@ -19,7 +19,7 @@ use strict; | |||
19 | use warnings; | 19 | use warnings; |
20 | use File::Basename; | 20 | use File::Basename; |
21 | use File::Copy; | 21 | use File::Copy; |
22 | use vars qw($V $C $t $l $e $E $s $S $i $v $f); | 22 | use vars qw($V $C $t $l $e $E $s $S $i $v $f $F); |
23 | use IPC::Open2; | 23 | use IPC::Open2; |
24 | use IPC::Open3; | 24 | use IPC::Open3; |
25 | use Digest::MD5 qw(md5_hex); | 25 | use Digest::MD5 qw(md5_hex); |
@@ -64,6 +64,8 @@ Usage: voice.pl [options] [path to dir] | |||
64 | Options to pass to the TTS engine. Enclose in double quotes if the | 64 | Options to pass to the TTS engine. Enclose in double quotes if the |
65 | options include spaces. | 65 | options include spaces. |
66 | 66 | ||
67 | -F Force the file to be regenerated even if present | ||
68 | |||
67 | -v | 69 | -v |
68 | Be verbose | 70 | Be verbose |
69 | USAGE | 71 | USAGE |
@@ -125,6 +127,7 @@ my %espeak_lang_map = ( | |||
125 | ); | 127 | ); |
126 | 128 | ||
127 | my $trim_thresh = 500; # Trim silence if over this, in ms | 129 | my $trim_thresh = 500; # Trim silence if over this, in ms |
130 | my $force = 0; # Don't regenerate files already present | ||
128 | 131 | ||
129 | # Initialize TTS engine. May return an object or value which will be passed | 132 | # Initialize TTS engine. May return an object or value which will be passed |
130 | # to voicestring and shutdown_tts | 133 | # to voicestring and shutdown_tts |
@@ -427,7 +430,7 @@ sub generateclips { | |||
427 | } | 430 | } |
428 | 431 | ||
429 | # Don't generate encoded file if it already exists (probably from the POOL) | 432 | # Don't generate encoded file if it already exists (probably from the POOL) |
430 | if (! -f $enc) { | 433 | if (! -f $enc && !$force) { |
431 | if ($id eq "VOICE_PAUSE") { | 434 | if ($id eq "VOICE_PAUSE") { |
432 | print("Use distributed $wav\n") if $verbose; | 435 | print("Use distributed $wav\n") if $verbose; |
433 | copy(dirname($0)."/VOICE_PAUSE.wav", $wav); | 436 | copy(dirname($0)."/VOICE_PAUSE.wav", $wav); |
@@ -540,7 +543,7 @@ sub gentalkclips { | |||
540 | 543 | ||
541 | printf("Talkclip %s: %s", $enc, $voice) if $verbose; | 544 | printf("Talkclip %s: %s", $enc, $voice) if $verbose; |
542 | # Don't generate encoded file if it already exists | 545 | # Don't generate encoded file if it already exists |
543 | next if (-f $enc); | 546 | next if (-f $enc && !$force); |
544 | 547 | ||
545 | voicestring($voice, $wav, $tts_engine_opts, $tts_object); | 548 | voicestring($voice, $wav, $tts_engine_opts, $tts_object); |
546 | wavtrim($wav, $trim_thresh, $tts_object); | 549 | wavtrim($wav, $trim_thresh, $tts_object); |
@@ -563,6 +566,7 @@ sub gentalkclips { | |||
563 | 566 | ||
564 | # Check parameters | 567 | # Check parameters |
565 | my $printusage = 0; | 568 | my $printusage = 0; |
569 | |||
566 | unless (defined($V) or defined($C)) { print("Missing either -V or -C\n"); $printusage = 1; } | 570 | unless (defined($V) or defined($C)) { print("Missing either -V or -C\n"); $printusage = 1; } |
567 | if (defined($V)) { | 571 | if (defined($V)) { |
568 | unless (defined($l)) { print("Missing -l argument\n"); $printusage = 1; } | 572 | unless (defined($l)) { print("Missing -l argument\n"); $printusage = 1; } |
@@ -575,6 +579,9 @@ if (defined($V)) { | |||
575 | elsif (defined($C)) { | 579 | elsif (defined($C)) { |
576 | unless (defined($ARGV[0])) { print "Missing path argument\n"; $printusage = 1; } | 580 | unless (defined($ARGV[0])) { print "Missing path argument\n"; $printusage = 1; } |
577 | } | 581 | } |
582 | |||
583 | $force = 1 if (defined($F)); | ||
584 | |||
578 | unless (defined($e)) { print("Missing -e argument\n"); $printusage = 1; } | 585 | unless (defined($e)) { print("Missing -e argument\n"); $printusage = 1; } |
579 | unless (defined($E)) { print("Missing -E argument\n"); $printusage = 1; } | 586 | unless (defined($E)) { print("Missing -E argument\n"); $printusage = 1; } |
580 | unless (defined($s)) { print("Missing -s argument\n"); $printusage = 1; } | 587 | unless (defined($s)) { print("Missing -s argument\n"); $printusage = 1; } |