how to play mp3

前端 未结 12 1685
醉酒成梦
醉酒成梦 2021-02-09 09:39

my problem starts here:

pyttsx and gTTS module errors

gTTS works well, takes text from text file, but first creates mp3 file, then if I want listen, I must call

12条回答
  •  难免孤独
    2021-02-09 10:22

    You can use "subprocess".

    from subprocess import call
    from gtts import gTTS
    import os
    blabla = input('Type IN: ')
    tts = gTTS(text=blabla, lang='en')
    tts.save("test.mp3")
    call(["vlc", "test.mp3"])
    

    This program asks user to type in anything and it will say that trough vlc.
    I use this on Linux but i don't now if it works on Windows.

提交回复
热议问题