Closed mifrey00 closed 3 years ago
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.
The problem must be elsewhere because I use very short sentences such as "Something to say".
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.
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.
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. https://github.com/zlargon/google-tts/issues/33
It's possible that there will have to be some upgrades in the near future to restore functionality.
I'm getting a "Get Key Failed From Google" error.
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.
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.
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.
3.2.7 published with short cut for now.
I'm gonna close this as fixed for now... if you end up having an issues, reopen.
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.