1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Solomon Peachy 2024-04-17 14:42:36 -04:00
parent ebd952da2f
commit c38aeb3fbc
2 changed files with 21 additions and 4 deletions

View file

@ -374,7 +374,17 @@ ifdef TTS_ENGINE
voice: voicetools $(BUILDDIR)/apps/features voice: voicetools $(BUILDDIR)/apps/features
$(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \ $(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 endif

View file

@ -19,7 +19,7 @@ use strict;
use warnings; use warnings;
use File::Basename; use File::Basename;
use File::Copy; 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::Open2;
use IPC::Open3; use IPC::Open3;
use Digest::MD5 qw(md5_hex); 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 to pass to the TTS engine. Enclose in double quotes if the
options include spaces. options include spaces.
-F Force the file to be regenerated even if present
-v -v
Be verbose Be verbose
USAGE USAGE
@ -125,6 +127,7 @@ my %espeak_lang_map = (
); );
my $trim_thresh = 500; # Trim silence if over this, in ms 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 # Initialize TTS engine. May return an object or value which will be passed
# to voicestring and shutdown_tts # to voicestring and shutdown_tts
@ -427,7 +430,7 @@ sub generateclips {
} }
# Don't generate encoded file if it already exists (probably from the POOL) # 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") { if ($id eq "VOICE_PAUSE") {
print("Use distributed $wav\n") if $verbose; print("Use distributed $wav\n") if $verbose;
copy(dirname($0)."/VOICE_PAUSE.wav", $wav); copy(dirname($0)."/VOICE_PAUSE.wav", $wav);
@ -540,7 +543,7 @@ sub gentalkclips {
printf("Talkclip %s: %s", $enc, $voice) if $verbose; printf("Talkclip %s: %s", $enc, $voice) if $verbose;
# Don't generate encoded file if it already exists # 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); voicestring($voice, $wav, $tts_engine_opts, $tts_object);
wavtrim($wav, $trim_thresh, $tts_object); wavtrim($wav, $trim_thresh, $tts_object);
@ -563,6 +566,7 @@ sub gentalkclips {
# Check parameters # Check parameters
my $printusage = 0; my $printusage = 0;
unless (defined($V) or defined($C)) { print("Missing either -V or -C\n"); $printusage = 1; } unless (defined($V) or defined($C)) { print("Missing either -V or -C\n"); $printusage = 1; }
if (defined($V)) { if (defined($V)) {
unless (defined($l)) { print("Missing -l argument\n"); $printusage = 1; } unless (defined($l)) { print("Missing -l argument\n"); $printusage = 1; }
@ -575,6 +579,9 @@ if (defined($V)) {
elsif (defined($C)) { elsif (defined($C)) {
unless (defined($ARGV[0])) { print "Missing path argument\n"; $printusage = 1; } 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($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; } unless (defined($s)) { print("Missing -s argument\n"); $printusage = 1; }