Python gTTS不保存MP3文件

Python gTTS不保存MP3文件,python,artificial-intelligence,google-text-to-speech,Python,Artificial Intelligence,Google Text To Speech,我想用Python创建一个人工智能程序。我发现我需要GTT,但它不能保存mp3文件。请帮帮我 #gtts is imported def talkToMe(audio, lgg = 'en'): #print(audio) tts = gTTS(text = audio, lang = lgg) #tts.save('audio.mp3') #doesn't work with open("audio.mp3") as fp: #doesn't work

我想用Python创建一个人工智能程序。我发现我需要GTT,但它不能保存mp3文件。请帮帮我

#gtts is imported
def talkToMe(audio, lgg = 'en'):
    #print(audio)
    tts = gTTS(text = audio, lang = lgg)
    #tts.save('audio.mp3') #doesn't work
    with open("audio.mp3") as fp: #doesn't work
        tts.write_to_fp(fp)
    os.system('mpg123\mpg123.exe audio.mp3')

将上面的文件另存为text_2_speech.py作为示例。我已经尝试过了,它工作正常。从命令行输入python-W ignore text_2_speech.py,然后将文件另存为当前目录中的audio.mp3

这里有什么帮助吗?B4问这里我看了这篇文章,但它没有帮助我,你也可以试试。pip卸载gTTs令牌,这将卸载gTTs令牌版本==1.1.1。并且再次执行pip安装gTTs令牌,它将安装新版本的gTTs令牌==1.1.2
Traceback (most recent call last):
  File "C:\Users\zigzag\Desktop\gtts_test1\main.py", line 9, in <module>
    talkToMe("hello")
  File "C:\Users\zigzag\Desktop\gtts_test1\main.py", line 7, in talkToMe
    tts.write_to_fp(fp)
  File "B:\Python36\lib\site-packages\gtts\tts.py", line 187, in write_to_fp
    part_tk = self.token.calculate_token(part)
  File "B:\Python36\lib\site-packages\gtts_token\gtts_token.py", line 28, in calculate_token
    seed = self._get_token_key()
  File "B:\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'
from gtts import gTTS    
#gtts is imported
audio = 'Hello , I am Tina, your digital assistant'
def talkToMe(audio, lgg = 'en'):
    #print(audio)
    tts = gTTS(text = audio, lang = lgg)
    tts.save('audio.mp3') #doesn't work
    return None
talkToMe(audio , lgg ='en')