Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTS timeout #38

Closed
mifrey00 opened this issue Nov 8, 2020 · 11 comments
Closed

TTS timeout #38

mifrey00 opened this issue Nov 8, 2020 · 11 comments

Comments

@mifrey00
Copy link

mifrey00 commented Nov 8, 2020

I systematically get the following error for some time now "FetchError: response timeout at https://translate.google.com over limit: 10000". It is not a network issue since it works with an URL pointing to an MP3 file.

Node version 3.2.6.

@i8beef
Copy link
Owner

i8beef commented Nov 8, 2020

Yes, Google translate limits you to sentences that are under 1000 characters in length. Sorry, that's a hard limit I have no control over.

@mifrey00
Copy link
Author

mifrey00 commented Nov 8, 2020

The problem must be elsewhere because I use very short sentences such as "Something to say".

@i8beef
Copy link
Owner

i8beef commented Nov 8, 2020

Oh, my mistake, you would get a range error if you were sending more than 200 characters at a time, not 10k. That looks like a network timeout calling google translate. If it takes over 10 seconds to get a response, you would get this.

@mifrey00
Copy link
Author

mifrey00 commented Nov 8, 2020

Yes that is a timeout of 10s but I do not understand why. If I use type MEDIA instead of TTS and use the URL https://translate.google.com/translate_tts?ie=UTF-8&q=%22Ceci%20est%20un%20test%22&tl=fr-FR&client=tw-ob , it is almost instantaneous.

@i8beef
Copy link
Owner

i8beef commented Nov 9, 2020

Hmm mine is currently still working, but it looks like the google-tts library folks are tracking some changes Google is making to the TTS API's availability. zlargon/google-tts#33

It's possible that there will have to be some upgrades in the near future to restore functionality.

@arachnida
Copy link

I'm getting a "Get Key Failed From Google" error.

@i8beef
Copy link
Owner

i8beef commented Nov 10, 2020

Yes, that's the linked issue to google-tts. Google has changed something about how this works and it's making various implementations unreliable. A hack was added to the library to try and deal with it (by retrying until it works, lol), but I think I'll wait for a more permanent solution to this. In the mean time, TTS service is going to be a little unreliable.

If nothing moves by this weekend, I think I can build a URL by convention instead... people seem to be unclear on if that is still reliable or not, but the "more correct" way this library was using to generate it is DEFINITELY getting broken by Google here, so it might be worth a shot.

@i8beef
Copy link
Owner

i8beef commented Nov 10, 2020

Note if it REALLY bothers you you can edit node_modules/node-red-contrib-castv2/lib/DefaultMediaReceiverAdapter.js and change this:

        return googletts(command.text, language, speed)
            .then(url => DefaultMediaReceiverAdapter.buildMediaObject({ url: url, contentType: "audio/mp3", metadata: metadata }))
            .then(media => receiver.loadAsync(media, { autoplay: true }));

to this:

        let url = "https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=" + language + "&q=" + encodeURIComponent(command.text);
        let media = DefaultMediaReceiverAdapter.buildMediaObject({ url: url, contentType: "audio/mp3", metadata: metadata });

        return receiver.loadAsync(media, { autoplay: true });

If there's not an update by this weekend, that's the change I'm gonna make. speed will no longer work with this, and there's some warnings Ive seen that if you abuse this too much Google will block your IP, but it seems to work for me.

@arachnida
Copy link

Thanks for your support, will try this out one of the coming days. My RPi is now working headless, so I need some time to get this working.

@i8beef
Copy link
Owner

i8beef commented Nov 15, 2020

3.2.7 published with short cut for now.

@i8beef
Copy link
Owner

i8beef commented Nov 17, 2020

I'm gonna close this as fixed for now... if you end up having an issues, reopen.

@i8beef i8beef closed this as completed Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants