Comments (8)
This is a single test request that I made just now. There is no other activity from my app today, besides a few tests from myself. The application worked fine until it decided to start returning status code 429, without any code changes.
Today, after seeing your note about the batch update, I did quickly update the code to send batches, because each translation request that my app creates actually requests for multiple languages. So I am now using the batch request, which should take my 20 requests per day down to maybe 4 per day.
from google-translate-api.
Issue 12 wasn't finished being addressed before it was closed. My app wouldn't hit the rate limit as it sends fewer than 20 requests per day.
I closed it because there was no response after several days of it attempting to be addressed.
from google-translate-api.
This is a single test request that I made just now. There is no other activity from my app today, besides a few tests from myself. The application worked fine until it decided to start returning status code 429, without any code changes.
Can you share your code? I'm not able to reproduce the issue.
from google-translate-api.
const key = require('./api.json')
const { Telegraf } = require('telegraf')
// const fs = require('fs')
const bot = new Telegraf(key.key)
const { Worker } = require('worker_threads')
const translate = require('google-translate-api-x')
bot.start((ctx) => ctx.reply('SSQ Translation Bot'))
bot.on('message', (ctx) => printTranslations(ctx.message.text, ctx))
bot.launch()
process.once('SIGINT', () => bot.stop('SIGINT'))
process.once('SIGTERM', () => bot.stop('SIGTERM'))
async function printTranslations(text, ctx) {
let res = await translateFive(text)
if (res) {
const languages = {
'en': 'English',
'es': 'Español',
'de': 'Deutsch',
'pl': 'Polski',
'ru': 'Русский',
'cn': '中文',
}
let translated = ''
Object.keys(languages).forEach(key => {
translated += `*${languages[key]}:* ${res[key]}`
translated += '\n\n'
})
// ctx.reply(translated, {reply_to_message_id: ctx.message.message_id})
ctx.replyWithMarkdownV2(translated, {reply_to_message_id: ctx.message.message_id})
}
}
async function translateFive(text) {
const textArray = [
{text: text, to: 'en'},
{text: text, to: 'es'},
{text: text, to: 'de'},
{text: text, to: 'ru'},
{text: text, to: 'pl'},
{text: text, to: 'zn-CN'},
];
try {
const translated = await translate(textArray);
return {
'en': translated[0].text,
'es': translated[1].text,
'de': translated[2].text,
'ru': translated[3].text,
'pl': translated[4].text,
'cn': translated[5].text,
}
} catch (e) {
console.log(e.message);
return null;
}
}
console.log('Bot running.')
from google-translate-api.
And this was the original one, as of this morning, before switching to the new batch feature.
const key = require('./api.json')
const { Telegraf } = require('telegraf')
const bot = new Telegraf(key.key)
const { Worker } = require('worker_threads')
const translate = require('google-translate-api-x')
bot.start((ctx) => ctx.reply('SSQ Translation Bot'))
bot.on('message', (ctx) => printTranslations(ctx.message.text, ctx))
bot.launch()
process.once('SIGINT', () => bot.stop('SIGINT'))
process.once('SIGTERM', () => bot.stop('SIGTERM'))
async function printTranslations(text, ctx) {
let res = await translateFive(text)
const languages = {
'en': 'English',
'es': 'Español',
'de': 'Deutsch',
'pl': 'Polski',
'ru': 'Русский',
'cn': '中文',
}
let translated = ''
Object.keys(languages).forEach(key => {
translated += `*${languages[key]}:* ${res[key]}`
translated += '\n\n'
})
ctx.replyWithMarkdownV2(translated, {reply_to_message_id: ctx.message.message_id})
}
async function translateFive(text) {
let en = await translate(text, {to: 'en'})
let es = await translate(text, {to: 'es'})
let de = await translate(text, {to: 'de'})
let ru = await translate(text, {to: 'ru'})
let pl = await translate(text, {to: 'pl'})
let cn = await translate(text, {to: 'zh-CN'})
return {
'en': en.text,
'es': es.text,
'de': de.text,
'ru': ru.text,
'pl': pl.text,
'cn': cn.text,
}
}
console.log('Bot running.')
from google-translate-api.
I migrated the server to a new IP address and I seem to have full operation at this point. Maybe the rate limit being hit was tied to that IP address somehow. Possibly from where I was sending 5 requests per translation. I'm kind of grasping at straws here, but at least for the time being, it seems to be working with the new IP address and using batch requests. I'll update you if anything changes.
from google-translate-api.
I'm kind of grasping at straws here, but at least for the time being, it seems to be working with the new IP address and using batch requests. I'll update you if anything changes.
Okay that's good, my best guess is that Google detected in some way your behavior as malicious and rate limited you, but I can't reproduce it.
from google-translate-api.
Closed as stale
from google-translate-api.
Related Issues (20)
- Autocorrect not properly applied to translations from certain networks HOT 6
- Real-time translation HOT 2
- ReferenceError: fetch is not defined HOT 2
- TypeScript Error HOT 2
- requestOptions documentation outdated HOT 3
- It throws error "fetch is not defined" HOT 2
- Tests fail only because rate limited on single translate HOT 1
- TypeError: (0 , _googleTranslateApiX.translate) is not a function HOT 17
- google-translate-api-x gives below error HOT 3
- Improve `speak` testing
- Caught an error from batch translate HOT 8
- ERROR [TypeError: Cannot convert null value to object] HOT 2
- Issue with the speak functionality HOT 2
- Batch translation error HOT 4
- Can't run on React.js HOT 2
- Big translation slowed down HOT 11
- change speak speed HOT 2
- fetch is not defined after deployment HOT 2
- CORS policy error HOT 4
- Obtain translation synonyms HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-translate-api.