Text-to-speech (TTS) module that works under Python 3

前端 未结 4 1917
隐瞒了意图╮
隐瞒了意图╮ 2021-02-08 23:31

I have tried PyTTS (deprecated) and PyTTSx (the most recommended) and two Google TTS solutions (gTTS and another one by some guy named Hung Truong) but none of them worked under

4条回答
  •  天命终不由人
    2021-02-09 00:18

    A user on Reddit found a solution.

    Turns out that gTTS works under Python 3.x, it was me that was importing the module wrong.

    I was using:

    import gtts
    blabla = ("Spoken text")
    tts = gTTS(text=blabla, lang='en')
    tts.save("C:/test.mp3")
    

    Resulting in the following error:

    NameError: name 'gTTS' is not defined
    

    When the correct way is:

    from gtts import gTTS
    blabla = ("Spoken text")
    tts = gTTS(text=blabla, lang='en')
    tts.save("C:/test.mp3")
    

提交回复
热议问题