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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值