Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ you may define AWS_KEY_ID and AWS_SECRET_ACCESS_KEY as environmental variables.
perl render.pl -i file [-o directory] [-c directory] [-s speeds] [-p pitch] [-pr]
[-m max processes] [-z 1] [-rr 1] [--test] [-l word limit]
[--norepeat] [--nospoken] [--nocourtesytone] [-e NEURAL | STANDARD]
[--sm] [--ss] [--sv] [-x] [--lang ENGLISH | SWEDISH]
[--sm] [--ss] [--sv] [-x] [--lang ENGLISH | SWEDISH | ROMANIAN]

Uses AWS Polly and requires valid credentials in the aws.properties file.<br/><br/>

For `-l ROMANIAN`, remember to use `-e STANDARD`. Neural languages do not sound as rough as standard ones.

#### OPTIONS:

##### Required:
Expand Down
11 changes: 9 additions & 2 deletions render.pl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Getopt::Long;
use Digest::SHA qw(sha256_hex sha256_base64);
use POSIX;
use Encode qw(encode_utf8);

my @speeds;
sub print_usage;
Expand Down Expand Up @@ -83,6 +84,10 @@
$lower_lang_chars_regex = "a-züäöß";
$upper_lang_chars_regex = "A-ZÜÄÖß";
}
if($lang eq "ROMANIAN") {
$lower_lang_chars_regex = "a-zâăîșț";
$upper_lang_chars_regex = "A-ZÂĂÎȘȚ";
}

binmode(STDOUT, ":encoding(UTF-8)");

Expand Down Expand Up @@ -408,7 +413,8 @@ sub split_on_spoken_directive {
$cached_filename = "${lang}-standard-";
}

$cached_filename .= $text_to_speech_engine . "-" . sha256_hex($sentence) . ".mp3";
use Encode qw(encode_utf8);
$cached_filename .= $text_to_speech_engine . "-" . sha256_hex(encode_utf8($sentence)) . ".mp3";
$cached_filename = $cache_directory . $cached_filename;

return $cached_filename;
Expand Down Expand Up @@ -581,7 +587,8 @@ sub split_on_spoken_directive {
sub get_cached_filename {
my ($ebookCmdBase, $morse_text) = @_;

my $cached_file_hash = sha256_base64($ebookCmdBase . $morse_text);
use Encode qw(encode_utf8);
my $cached_file_hash = sha256_base64(encode_utf8($ebookCmdBase . $morse_text));
$cached_file_hash =~ s/\///g;
my $cached_file = $cached_file_hash . ".mp3";

Expand Down
3 changes: 3 additions & 0 deletions text2speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ def render(cache_filename, voice_id, text_type, text):
if language == "GERMAN":
voice_id = "Vicki"

if language == "ROMANIAN":
voice_id = "Carmen"

print("Using Voice: " + voice_id)
cache_filename = cache_directory + language + "-standard-" + base_filename
render(cache_filename, voice_id=voice_id, text_type=None, text=sentence)
Expand Down