Translate: BadRequest: "Too many text segments"
See original GitHub issueCode example:
from google.cloud import translate
def translate_phrases(text, target_lang='es'):
global translate_client
translation = translate_client.translate(
text,
target_language=target_lang)
translated_texts = []
for obj in translation:
translated_texts.append(obj['translatedText'])
return translated_texts
Error obtained: BadRequest: 400 POST https://translation.googleapis.com/language/translate/v2: Too many text segments
Input: Python list of strings totaling up 819 characters.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
"Too many text segments" error in Google translate API
As mentioned in this documentation, the total number of strings (segments) that can be sent for translation per request is limited to 128....
Read more >Translate API error: "Too many text segments"
Hi, What's the limit for the number of text segments that can be sent to the Google Translate API v2? I get an...
Read more >"Too Many Text Segments" Error In Google Translate Api
Lists languages from Google Translate API #' #' Returns a list of Too many text segments|Request payload size exceeds the limit|Text too long...
Read more >CTSX Google Translator
The CTSX Google module performs translation via the Google Cloud Translation API. ... TranslateException: Too many text segments Caused by: ...
Read more >Re: Translate API error: "Too many text segments ...
Yes, I get the limit at 128 as well. I'll have to split the N text segments into several HTTP Requests of 128...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I did some investigating and you can send up to 128 segments. There are also limitations on the number of overall characters, but that is well documented on failure.
Request payload size exceeds the limit: 204800 bytes.
I have requested that the error for too many segments informs you of how many segments are allowed.
I am seeing the same problem in C# too.
May be related to: https://github.com/googleapis/google-cloud-dotnet/issues/2957
The problem IMO is that the limits seem arbitrary and it makes for junky and/or inefficient end code.