Google Text-To-Speech API 的保存(文件)运行速度很慢

Hoa*_*uan 6 python performance python-3.x google-text-to-speech

我是 Python 的新手。我最近一直在使用 gTTS,但遇到了性能问题。这是代码:

    from gtts import gTTS
    import pygame
    import time

    tts = gTTS(text='Good morning', lang='en') #<1s
    tts.save('test.mp3') # 30-60s
    pygame.mixer.pre_init()
    pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=512)
    pygame.init()
    player = pygame.mixer.music
    player.load('test.mp3')
    player.play() # <1s
    time.sleep(5)
Run Code Online (Sandbox Code Playgroud)

我在窗口 7 上使用 Python 3.4。这个性能问题对我的项目来说是非常致命的。任何帮助将不胜感激。