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

前端 未结 4 1860
隐瞒了意图╮
隐瞒了意图╮ 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:19

    I just installed gtts 1.0.7 that was uploaded on 2015-10-07

    The following code works for me in Python 3.5:

    import subprocess
    from gtts import gTTS
    
    audio_file = "hello.mp3"
    tts = gTTS(text="Hello World!", lang="en")
    tts.save(audio_file)
    return_code = subprocess.call(["afplay", audio_file])
    

    I'm on a Mac using in the inbuilt "afply" to play the mp3 but there are other ways e.g. Playing mp3 song on python

提交回复
热议问题