Issue
Pre
I have seen questions about this kind of error , but it was not related with gTTS
.
I use gTTS
module.One day,this error suddenly happened.Yes,I have never handled these codes from the time of importing it.Until yesterday,this error didn't happen.
It happened when I excute this code:
Code
sounditems = [i for i in gtts.lang.tts_langs().values()]
Error
RuntimeError: Unable to get language list: 'NoneType' object is not subscriptable
In [1]: import gtts
In [2]: gtts.lang
Out[2]: <module 'gtts.lang' from 'C:\\Anaconda3\\lib\\site-packages\\gtts\\lang.py'>
In [3]: gtts.lang.tts_langs()
Traceback (most recent call last):
File "<ipython-input-3-53b538afe087>", line 1, in <module>
gtts.lang.tts_langs()
File "C:\Anaconda3\lib\site-packages\gtts\lang.py", line 41, in tts_langs
raise RuntimeError("Unable to get language list: %s" % str(e))
RuntimeError: Unable to get language list: 'NoneType' object is not subscriptable
gTTS version
Editor
In [7]: spyder.version_info
Out[7]: (3, 2, 8)
language
python 3.6.5
After search
I investigated in gTTS lang module.I thought it failes to get imformation from Google.Perhaps,it may not be the problem on the client side.
Added
After researching the lang.py
module,I found out the source of error was from its _fetch_langs()
function & it seems to have failed to execute soup.find(src=re.compile(JS_FILE))['src']
.
--result
--long html code--
Solution
gTTS 2.0.3
is already released.
I reinstalled gTTS module by following John D. and I updated lang.py
.
I rewrote my original code from
gtts.lang.tts_langs()
to
gtts.tts.tts_langs()
I could solve the problem.
This is not the mirrored answer for my question,but I'm very satisfied.
It seems that gtts module can be updated in the future and is under development now.
I have no reason for persisting to gTTS 2.0.1
Answered By - Haru
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.