py-googletrans icon indicating copy to clipboard operation
py-googletrans copied to clipboard

TypeError: the JSON object must be str, bytes or bytearray, not NoneType

Open imrankh46 opened this issue 1 year ago • 11 comments

I am using version 4 , but I got the above error. I am using the following code

from googletrans import Translator

# Create a translator object
translator = Translator()

# Open the input file
with open('poems.txt', 'r') as file:
    input_text = file.read()

# Split the input text into smaller chunks (e.g. sentences or paragraphs)
input_chunks = [chunk.strip() for chunk in input_text.split('\n')]

# Translate each chunk
output_chunks = []
for chunk in input_chunks:
    output_chunk = translator.translate(chunk, dest='ur').text
    output_chunks.append(output_chunk)

# Join the output chunks into a single string
output_text = '\n'.join(output_chunks)

# Open the output file
with open('output.txt', 'w') as file:
    file.write(output_text)

imrankh46 avatar May 07 '23 15:05 imrankh46

I solved this issue with another library (https://github.com/suqingdong/googletranslatepy). I think that this library is dead.

sharmankin avatar May 10 '23 07:05 sharmankin

I have the same error and as I see, responses sometimes are really strange, but not empty at all, there are some strange google codes. And I can't understand what's the principle of getting normal response or just "empty", looks like it's on the Google side, but IDK.

sevvvich avatar May 27 '23 16:05 sevvvich

I solved this issue with another library (https://github.com/suqingdong/googletranslatepy). I think that this library is dead.

When the token limit exceed, so they give this error.

imrankh46 avatar May 27 '23 16:05 imrankh46

I have the same error and as I see, responses sometimes are really strange, but not empty at all, there are some strange google codes. And I can't understand what's the principle of getting normal response or just "empty", looks like it's on the Google side, but IDK.

When the token limit exceed so they show this type of behavior.

imrankh46 avatar May 27 '23 16:05 imrankh46

I solved this issue with another library (https://github.com/suqingdong/googletranslatepy). I think that this library is dead.

Thanks for suggestion.

imrankh46 avatar May 27 '23 16:05 imrankh46

I solved this issue with another library (https://github.com/suqingdong/googletranslatepy). I think that this library is dead.

Thanks for suggestion.

Do you think it's because of library or should we use some tricky ways to avoid token limitations for all free libraries?

sevvvich avatar May 28 '23 20:05 sevvvich

I solved this issue with another library (https://github.com/suqingdong/googletranslatepy). I think that this library is dead.

Thanks for suggestion.

Do you think it's because of library or should we use some tricky ways to avoid token limitations for all free libraries?

Yeah it's token limitations issues. I think at a time the library can translate 1500 token or 5000, but when the length are exceed, they showing this error.

Do you think, the new library also showing this behavior?

imrankh46 avatar May 29 '23 02:05 imrankh46

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 12 '23 13:08 stale[bot]

rip

bulk doesn't work anymore, this doesn't work for example: translations = translator.translate(["The quick brown fox"], dest='fr'), google returns [['wrb.fr', 'MkEWBc', None, None, None, [3], 'generic'], ['di', 13], ['af.httprm', 13, '3204246270318709149', 19]]

Knackii avatar Aug 15 '23 05:08 Knackii

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 15 '23 12:10 stale[bot]

pip install googletrans==3.1.0a0

lionderful avatar Apr 12 '24 07:04 lionderful