当前位置:   article > 正文

python代码提示 ts,如何在python中使用gTTS?

python 的ts在哪个包

When executing the below code

from gtts import gTTS

tts = gTTS('hello')

tts.save('hello.mp3')

I am getting "AttributeError: 'NoneType' object has no attribute 'group'".

Traceback (most recent call last):

File "C:\Users\HP\Desktop\Desktop\programming\Python_code\New Text Document - Copy (8) - Copy.py", line 3, in

tts.save('hello.mp3')

File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\gtts\tts.py", line 247, in save

self.write_to_fp(f)

File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\gtts\tts.py", line 187, in write_to_fp

part_tk = self.token.calculate_token(part)

File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\gtts_token\gtts_token.py", line 28, in calculate_token

seed = self._get_token_key()

File "C:\Users\HP\AppData\Local\Programs\Python\Python36\lib\site-packages\gtts_token\gtts_token.py", line 62, in _get_token_key

a = re.search("a\\\\x3d(-?\d+);", tkk_expr).group(1)

AttributeError: 'NoneType' object has no attribute 'group'

Is it possible to use gTTS in Python?

解决方案

There is an official fix now. It had to do with an upstream dependency of gtts, gtts-token. It has been fixed in gtts-token==1.1.2

My issue was fixed after I did a fresh install of both gtts and gtts-token.

The relevant github issue in gtts can be found here. Amazing this issue was fixed in 12 hours. Praise the open source gods! :D

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/945893
推荐阅读
相关标签
  

闽ICP备14008679号