Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Commit

Permalink
Possible fix for for the Google TTS 'API'
Browse files Browse the repository at this point in the history
Thanks to @sympoz
  • Loading branch information
glutanimate committed Nov 6, 2016
1 parent 2c96c38 commit 503963b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion simple_google_tts
Expand Up @@ -2,7 +2,7 @@

# NAME: Simple Google TTS
# VERSION: 0.1
# AUTHOR: (c) 2014 Glutanimate <https://github.com/Glutanimate/>
# AUTHOR: (c) 2014 - 2016 Glutanimate <https://github.com/Glutanimate/>
# DESCRIPTION: Wrapper script for Michal Fapso's speak.pl Google TTS script
# DEPENDENCIES: - wrapper: xsel libttspico0 libttspico-utils libttspico-data libnotify-bin
# - speak.pl: libwww-perl libwww-mechanize-perl libhtml-tree-perl sox libsox-fmt-mp3
Expand Down
6 changes: 3 additions & 3 deletions speak.pl
Expand Up @@ -349,7 +349,7 @@ ()
sub GetSentenceResponse() {
my $sentence = shift;
my $amptk = int(rand(1000000)) . '|' . int(rand(1000000));
my $resp = $browser->get("https://translate.google.com/translate_tts?ie=UTF-8&tl=$language&q=$sentence&total=1&idx=0&client=t&tk=$amptk");
my $resp = $browser->get("https://translate.google.com/translate_tts?ie=UTF-8&tl=$language&q=$sentence&total=1&idx=0&client=tw-ob&tk=$amptk");

if ($resp->content =~ "^<!DOCTYPE" ||
$resp->content =~ "^<html>")
Expand All @@ -363,10 +363,10 @@ ()
my $sentence = shift;

my $recaptcha_waiting = 0;
print "URL: https://translate.google.com/translate_tts?ie=UTF-8&tl=$language&q=$sentence&total=1&idx=0&client=t\n";
print "URL: https://translate.google.com/translate_tts?ie=UTF-8&tl=$language&q=$sentence&total=1&idx=0&client=tw-ob\n";
while (1) {
my $amptk = int(rand(1000000)) . '|' . int(rand(1000000));
my $url = "https://translate.google.com/translate_tts?ie=UTF-8&tl=$language&q=$sentence&total=1&idx=0&client=t&tk=$amptk";
my $url = "https://translate.google.com/translate_tts?ie=UTF-8&tl=$language&q=$sentence&total=1&idx=0&client=tw-ob&tk=$amptk";
$mech->get($url); $mech->add_header( Referer => "$referer" ); $referer = $url;
if ($mech->response()->content() =~ /^<!DOCTYPE/ ||
$mech->response()->content() =~ /^<html>/)
Expand Down

0 comments on commit 503963b

Please sign in to comment.