问题描述
我试图将 gtts 用于临时聊天机器人 AI,此代码为 tts
def say_sentence(sentence):
tts = gTTS(sentence,'en')
#ps,this lib is installed with pip install gtts
f = TemporaryFile()
tts.write_to_fp(f)
#ps,this lib is installed with pip install audioplayer
AudioPlayer(f).play(block=True)
Traceback (most recent call last):
File "c:/Users/giuse/OneDrive/Desktop/Apps/Py/chatterbot/chatbot.py",line 34,in <module>
say_sentence(response)
File "c:/Users/giuse/OneDrive/Desktop/Apps/Py/chatterbot/chatbot.py",line 14,in say_sentence
tts.write_to_fp(f)
File "D:\Softwares\Python 3.8\lib\site-packages\gtts\tts.py",line 258,in write_to_fp
prepared_requests = self._prepare_requests()
File "D:\Softwares\Python 3.8\lib\site-packages\gtts\tts.py",line 193,in _prepare_requests
text_parts = self._tokenize(self.text)
File "D:\Softwares\Python 3.8\lib\site-packages\gtts\tts.py",line 157,in _tokenize
text = text.strip()
AttributeError: 'Statement' object has no attribute 'strip'
我正在尝试解决这个问题,但没有成功,有什么帮助吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)