summaryrefslogtreecommitdiffstats
path: root/tools/release/voices.pl
blob: c0bac95b1c264dee608dc44ba07db7c2ba8e1411 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/perl -w
require "./tools/builds.pm";

my $verbose;
if($ARGV[0] eq "-v") {
    $verbose =1;
    shift @ARGV;
}

my $tag = $ARGV[0];
my $version = $ARGV[1];

my $outdir = "output/voices";

# made once for all targets
sub runone {
    my ($target, $name, $lang, $engine, $voice, $engine_opts)=@_;
    my $a;

    print "*** LANGUAGE: $lang\n";

    print "Build in buildv-$target-$lang\n" if($verbose);

    mkdir "buildv-$target-$lang";
    chdir "buildv-$target-$lang";

    # build the voice(s)
    $a = buildit($target, $lang, $engine, $voice, $engine_opts);

    my $o="$lang.voice";
    if (-f $o) {
        my $newo="../$outdir/$target/voice-$target-$version-$name.zip";
	system("mkdir -p ../$outdir/$target");
        system("mkdir -p .rockbox/langs");
        system("mkdir -p output/$target");
        system("mkdir -p .rockbox/langs");
        system("cp $o .rockbox/langs");
        system("cp $lang.lng.talk .rockbox/langs");
        system("cp InvalidVoice_$lang.talk .rockbox/langs");
        system("zip -q -r $newo .rockbox");
        system("rm -rf .rockbox");
        `chmod a+r $newo`;
        print "moved $o to $newo\n" if($verbose);
    }

    chdir "..";

    print "remove all contents in buildv-$target-$lang\n" if($verbose);
    system("rm -rf buildv-$target-$lang");

    return $a;
};

sub buildit {
    my ($target, $lang, $engine, $voice, $engine_opts)=@_;

    `rm -rf * >/dev/null 2>&1`;

    my $c = "../tools/configure --no-ccache --type=av --target=$target --ram=-1 --language=$lang --tts=$engine --voice=$voice --ttsopts='$engine_opts'";

    print "C: $c\n" if($verbose);
    system($c);

    print "Run 'make voice'\n" if($verbose);
    `make voice`;
}

`git checkout $tag`;

# run make in tools first to make sure they're up-to-date
`(cd tools && make ) >/dev/null 2>&1`;

if (!defined($ENV{'POOL'})) {
    my $home=$ENV{'HOME'};
    my $pool="$home/tmp/rockbox-voices-$version/voice-pool";
    `mkdir -p $pool`;
    $ENV{'POOL'}="$pool";
}
# `rm -f $pool/*`;

`mkdir -p $outdir`;

for my $b (&stablebuilds) {
    next if ($builds{$b}{voice}); # no variants

    for my $v (&allvoices) {
	my %voice = %{$voices{$v}};

	my $engine = $voice{"defengine"};
	my ($opts, $vf);
	if ($engine eq 'piper') {
	    $vf = $voice{"engines"}->{$engine};
	    $opts = "";
	} else {
	    $vf = -1;
	    $opts = $voice{"engines"}->{$engine};
	}
	#            print " runone $b $v ($voice{lang} via $engine)\n";
	runone($b, $v, $voice{"lang"}, $engine, $vf, $opts);
    }
}