Skip to content

Commit

Permalink
Closes hollie#235
Browse files Browse the repository at this point in the history
  • Loading branch information
JaredF committed Jul 22, 2014
1 parent 5516ae4 commit 14b53fd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/Voice_Text.pm
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ sub speak_text {
my $google_file = "$main::config_parms{data_dir}/mh_temp.google-$random.mp3";

# Make the request, store the result in the google temp file
my $ua_request = HTTP::Request->new('GET' => "http://translate.google.com/translate_tts?tl=en&q=".qq[ $parms{text} ]);
my $language = ($main::config_parms{language}) ? lc($main::config_parms{language}) : "en";
my $ua_request = HTTP::Request->new('GET' => "http://translate.google.com/translate_tts?tl=$language&q=".qq[ $parms{text} ]);
my $ua_response = $ua->request($ua_request, $google_file);

# Log the failure
Expand All @@ -461,11 +462,12 @@ sub speak_text {
}

# Convert the returned mp3 file to a wav, and clean up the temp file
system("ffmpeg", "-loglevel", "panic", "-i", "$google_file", "$out_file");
my $sound_converter = ($main::config_parms{sound_converter}) ? $main::config_parms{sound_converter} : "ffmpeg";
system($sound_converter, '-v', 'panic', '-i', $google_file, $out_file);
unlink($google_file);

# Play the wav file, clean up only if we are not being forced to file
system($main::config_parms{sound_program}, $out_file) unless $parms{to_file};
system("$main::config_parms{sound_program} $out_file") unless $parms{to_file};
unlink($out_file) unless $parms{to_file};
}
elsif ($speak_pgm) {
Expand Down

0 comments on commit 14b53fd

Please sign in to comment.