question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error if text > 200 char

See original GitHub issue

I am currently running version 2.2.0 and it seems like if the text we are trying to convert is greater than 200 char, the conversion fails with the following message:

Traceback (most recent call last):
  File "main.py", line 11, in <module>
    myobj.save("audiobook.mp3")
  File "/usr/local/lib/python3.8/dist-packages/gtts/tts.py", line 311, in save
    self.write_to_fp(f)
  File "/usr/local/lib/python3.8/dist-packages/gtts/tts.py", line 293, in write_to_fp
    raise gTTSError(tts=self, response=r)
gtts.tts.gTTSError: 200 (OK) from TTS API. Probable cause: Unknown

Sample code to reproduce the problem:

from gtts import gTTS

finalChar = 201
language = 'en'
finalText = ""
for i in range(30):
    finalText += "\n0123456789"
print(finalText[:finalChar])

myobj = gTTS(text=finalText[:finalChar], lang=language, slow=False)
myobj.save("audiobook.mp3")

if you change back finalChar to 200, the request works and the file is written on disk.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:23 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
erichsu0527commented, Feb 2, 2021

Since zh is not a language, Chinese does not work at all.

from gtts import gTTS tts = gTTS(“说中文”, lang=“zh-CN”) tts.save(“helloch.mp3”) tts = gTTS(“說中文”, lang=“zh-TW”) tts.save(“helloch.mp3”)

Get “gtts.tts.gTTSError: 200 (OK) from TTS API. Probable cause: Unknown” on both tts.save()

2reactions
pndurettecommented, Feb 12, 2021

@KelvinKramp, @srugai & @NikithaNimbalkar:

The accents are back, just obtained differently!

I’ve added updated documentation on how to obtain local accents with the combination of the right language code (lang) and top-level domain (tld)! See: https://gtts.readthedocs.io/en/latest/module.html#localized-accents

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error message when a user enters more characters than max ...
Sure this is possible! First, count the entered characters and then print out the message you'd like to ...
Read more >
"Please enter a value using 200 characters or fewer." error on ...
If the phrase spam_prevention_registration_rejected is longer than 200 characters, then this error will occur instead of giving the actual ...
Read more >
Can't figure out this error: text, ntext - SQLServerCentral
a CHAR(200) data would be padded with spaces all the way out to the full defined size of 200 characters. Like2SQL (4/11/2010). Thanks...
Read more >
How to show error message when maximum limit exceed in ...
i had wrote the script,its allowing 1000 characters.its ok to me.at the same time need to show error message"text will not allow 1000...
Read more >
character limit in text field - Microsoft Dynamics CRM Forum ...
I am running into an issue with a workflow inserting data from other fields. On the Task Entity the Subject field has a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found