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 | |
parent | ebd952da2f50f73afa30554b0a0ad1a4dc5c7c63 (diff) | |
download | rockbox-c38aeb3fbc.tar.gz rockbox-c38aeb3fbc.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
-rw-r--r-- | tools/root.make | 12 | ||||
-rwxr-xr-x | tools/voice.pl | 13 |
2 files changed, 21 insertions, 4 deletions
diff --git a/tools/root.make b/tools/root.make index 03c4d48986..37aeaadaff 100644 --- a/tools/root.make +++ b/tools/root.make @@ -374,7 +374,17 @@ ifdef TTS_ENGINE voice: voicetools $(BUILDDIR)/apps/features $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \ - for lang in `echo $(VOICELANGUAGE) |sed "s/,/ /g"`; do $(TOOLSDIR)/voice.pl -V -l=$$lang -t=$(MODELNAME)$$feat -i=$(TARGET_ID) -e="$(ENCODER)" -E="$(ENC_OPTS)" -s=$(TTS_ENGINE) -S="$(TTS_OPTS)"; done \ + for lang in `echo $(VOICELANGUAGE) |sed "s/,/ /g"`; do $(TOOLSDIR)/voice.pl -V -l=$$lang -t=$(MODELNAME)$$feat -i=$(TARGET_ID) -e="$(ENCODER)" -E="$(ENC_OPTS)" -s=$(TTS_ENGINE) -S="$(TTS_OPTS)"; done + +talkclips: voicetools + $(SILENT)if [ -z '$(TALKDIR)' ] ; then \ + echo "Must specify TALKDIR"; \ + else \ + for lang in `echo $(VOICELANGUAGE) |sed "s/,/ /g"`; do $(TOOLSDIR)/voice.pl -C -l=$$lang -e="$(ENCODER)" -E="$(ENC_OPTS)" -s=$(TTS_ENGINE) -S="$(TTS_OPTS)" $(FORCE) "$(TALKDIR)" ; done \ + fi + +talkclips-force: FORCE=-F +talkclips-force: talkclips endif 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; use warnings; use File::Basename; use File::Copy; -use vars qw($V $C $t $l $e $E $s $S $i $v $f); +use vars qw($V $C $t $l $e $E $s $S $i $v $f $F); use IPC::Open2; use IPC::Open3; use Digest::MD5 qw(md5_hex); @@ -64,6 +64,8 @@ Usage: voice.pl [options] [path to dir] Options to pass to the TTS engine. Enclose in double quotes if the options include spaces. + -F Force the file to be regenerated even if present + -v Be verbose USAGE @@ -125,6 +127,7 @@ my %espeak_lang_map = ( ); my $trim_thresh = 500; # Trim silence if over this, in ms +my $force = 0; # Don't regenerate files already present # Initialize TTS engine. May return an object or value which will be passed # to voicestring and shutdown_tts @@ -427,7 +430,7 @@ sub generateclips { } # Don't generate encoded file if it already exists (probably from the POOL) - if (! -f $enc) { + if (! -f $enc && !$force) { if ($id eq "VOICE_PAUSE") { print("Use distributed $wav\n") if $verbose; copy(dirname($0)."/VOICE_PAUSE.wav", $wav); @@ -540,7 +543,7 @@ sub gentalkclips { printf("Talkclip %s: %s", $enc, $voice) if $verbose; # Don't generate encoded file if it already exists - next if (-f $enc); + next if (-f $enc && !$force); voicestring($voice, $wav, $tts_engine_opts, $tts_object); wavtrim($wav, $trim_thresh, $tts_object); @@ -563,6 +566,7 @@ sub gentalkclips { # Check parameters my $printusage = 0; + unless (defined($V) or defined($C)) { print("Missing either -V or -C\n"); $printusage = 1; } if (defined($V)) { unless (defined($l)) { print("Missing -l argument\n"); $printusage = 1; } @@ -575,6 +579,9 @@ if (defined($V)) { elsif (defined($C)) { unless (defined($ARGV[0])) { print "Missing path argument\n"; $printusage = 1; } } + +$force = 1 if (defined($F)); + unless (defined($e)) { print("Missing -e argument\n"); $printusage = 1; } unless (defined($E)) { print("Missing -E argument\n"); $printusage = 1; } unless (defined($s)) { print("Missing -s argument\n"); $printusage = 1; } |