Support and General Use > User Interface and Voice
automatic talk file generator (perl/linux)
(1/1)
lfod:
The posted link for automatic talk file generation appeared to be Windows only, so I wrote a small perl script to generate the directory and filename talk files on a linux box. I use linux and have an iRiver H160 aka H140. If you know a bit of perl you can customize the script to your preferences. It requires text2wave (festival voice package) and lame, and I post the perl script below. If people think it would be useful I can clean the script up and make it a bit more configurable from the command line or even attach a GUI.
#!/usr/bin/env perl
# descend directory tree on H160 and add _dirname.talk
# files in each directory, and file.mp3.talk for voice menu to use
#
# requires text2wave, lame
use File::Find;
#sub wanted;
# change this line to point to your rockbox mount point
$top_dir = '/media/H160/music/';
$tmp = File::Find::find({wanted => \&wanted, follow_skip =>2}, $top_dir);
$tmp = File::Find::find({wanted => \&files, follow_skip =>2}, $top_dir);
# create a mp3 file foreach directory
foreach $d (sort keys %DIRS) {
@path = split(/\//, $d);
$dirname = pop @path;
$dirname =~ s/_/ /g;
print "$d $dirname\n";
open(OUT, ">filename.txt");
print OUT "$dirname\n";
close(OUT);
$cmd = "text2wave filename.txt -o _dirname.wav";
#print "$cmd\n";
system($cmd);
$cmd="lame _dirname.wav \"$d\/_dirname.talk\"";
#print "$cmd\n";
system($cmd);
}
# create a mp3 file for each ogg/mp3/mp4/wma/m3u file
foreach $f (sort keys %FILES) {
next if ($f =~ /\.talk$/);
@path = split(/\//, $f);
$filename = pop @path;
$filename =~ s/^\d+//;
$filename =~ s/_/ /g;
$filename =~ s/\.ogg//;
$filename =~ s/\.mp3/ mp3/;
$filename =~ s/\.mp4/ mp4/;
$filename =~ s/\.wma/ wma/;
$filename =~ s/\.m3u/ playlist/;
print "\nf:$f filename:$filename\n";
open(OUT, ">filename.txt");
print OUT "$filename\n";
close(OUT);
$cmd = "text2wave filename.txt -o tmp.wav";
#print "$cmd\n";
system($cmd);
$cmd="lame tmp.wav \"$f\.talk\"";
print "$cmd\n";
system($cmd);
}
sub wanted {
my ($dev,$ino,$mode,$nlink,$uid,$gid);
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))
&& (-d _)
# && print("$File::Find::dir\n")
&& ($DIRS{$File::Find::name} = 1);
}
sub files {
my ($dev,$ino,$mode,$nlink,$uid,$gid);
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))
&& (-f _)
# && print("$File::Find::dir\n")
&& ($FILES{$File::Find::name} = 1);
}
Llorean:
It would really be preferable if you attached this to the appropriate wiki page, the forums are not the appropriate place for such a thing.
Domonoky:
And also note that rbutil, can now also generate Talkfiles :-)
At the moment it supports only filte and espeak, but it works on linux, windows, and mac :-)
Navigation
[0] Message Index
Go to full version