Open Coalado opened 3 years ago
To create an API Key:
or, be google free: https://forum.iobroker.net/topic/45177/asterisk-bringt-error-while-dialing-2-error
I prefer this solution, addictions hurt ;-) regards Stefano
This will not work:
$ wget "https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=hallo%20du&tl=de&total=1&idx=0&textlen=10"
--2021-07-16 22:49:43-- https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=hallo%20du&tl=de&total=1&idx=0&textlen=10
Auflösen des Hostnamens translate.google.com (translate.google.com)… 142.250.185.238, 2a00:1450:4005:80b::200e
Verbindungsaufbau zu translate.google.com (translate.google.com)|142.250.185.238|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 403 Forbidden
2021-07-16 22:49:44 FEHLER 403: Forbidden.
This will work:
$ wget --user-agent='Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0' "https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=hallo%20du&tl=de&total=1&idx=0&textlen=10" --2021-07-16 22:51:58-- https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=hallo%20du&tl=de&total=1&idx=0&textlen=10
Auflösen des Hostnamens translate.google.com (translate.google.com)… 142.250.184.206, 2a00:1450:4001:802::200e
Verbindungsaufbau zu translate.google.com (translate.google.com)|142.250.184.206|:443 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: nicht spezifiziert [audio/mpeg]
Wird in »translate_tts?ie=UTF-8&client=tw-ob&q=hallo du&tl=de&total=1&idx=0&textlen=10« gespeichert.
translate_tts?ie=UTF-8&client=tw-ob&q=hallo du&tl=de&total= [ <=> ] 5,16K --.-KB/s in 0s
2021-07-16 22:51:58 (10,8 MB/s) - »translate_tts?ie=UTF-8&client=tw-ob&q=hallo du&tl=de&total=1&idx=0&textlen=10« gespeichert [5280]
So we can change in lib/transcode.js line 100 - 105
// https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=%D0%BE%D1%82%D0%B2%D0%B5%D1%82%D0%B8%D1%82%D1%8C%207&tl=ru&total=1&idx=0&textlen=10
const options = {
host: 'translate.google.com',
//port: 443,
path: '/translate_tts?ie=UTF-8&client=tw-ob&q=' + encodeURI(text) + '&tl=' + language + '&total=1&idx=0&textlen=' + text.length //
};
to
// https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=%D0%BE%D1%82%D0%B2%D0%B5%D1%82%D0%B8%D1%82%D1%8C%207&tl=ru&total=1&idx=0&textlen=10
const options = {
host: 'translate.google.com',
//port: 443,
path: '/translate_tts?ie=UTF-8&client=tw-ob&q=' + encodeURI(text) + '&tl=' + language + '&total=1&idx=0&textlen=' + text.length, //
headers: {'user-agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0'}
};
The API will only talk to firefox
Since several days/weeks, the adapter does not work any more.
I tracked the issue down to "The Google TTS API returns a "Forbidden"". It seems like the adapter is blocked because the same request works in the browser.
However, I updated the transcode.js to use the official Google API. (You need a google API key, but you have ~1.000.000 free characters)
Here is my code. Maybe somebody can implement this, a config option for the google API incl. Key, and re-implement the language/Voice options (which are hardcoded right now). Optionally: Build a Text->Mp3 cache to avoid sensing the same texts over and over...
To test the code:
}