Closed Triggered0 closed 3 years ago
Same issue here. Not able to get media file via google-tts:get token key failed from google
Google switched to a new API #35
This is a duplicate of #33
let me try to fix on https://github.com/zlargon/google-tts/pull/37
For anyone looking for an immediate solution, you can check out my comment I left in the other issue: https://github.com/zlargon/google-tts/issues/35#issuecomment-737032391
I created a new package google-translate-tts which uses the new Translate API. Who knows if the new API will stick, but it fixed the immediate problems I was having.
So tried when I saw this
This is my idea of api.js, but let me figure out how to merge it properly into api.js.
const fetch = require('node-fetch');
module.exports = (async (text, lang, speed) => {
const data =
JSON.parse(JSON.parse((await (await fetch("https://translate.google.com/_/TranslateWebserverUi/data/batchexecute", {
method: "POST",
headers: {
"content-type": "application/x-www-form-urlencoded"
},
body: "f.req=" + encodeURIComponent(JSON.stringify([
[
["jQ1olc", JSON.stringify([text, lang, parseInt(speed) === 1 ? null : true, "null"]), null, "generic"]
]
]))
})).text()).replace(/^\)]}'/, ''))[0][2])[0];
return `data:audio/mpeg;base64,${data}`;
});
Let me try to adopt ↑ at https://github.com/zlargon/google-tts/pull/38
This issue has been fixed in PR https://github.com/zlargon/google-tts/pull/37 by @freddiefujiwara and has been released in version 0.0.6. Thank you all. 🎉
Error: get token key failed from google