Search code examples
pythonpython-3.xgtts

How to make the computer speak in python?


I tried to use gtts:

from gtts import gTTs
import os

tts = gTTS(text='Good morning', lang='en')
tts.save("good.mp3")
os.system("mpg321 good.mp3")

But I got this error:

'mpg321' is not recognized as an internal or external command operable program or batch file.

Why does this happen? I even have portaudio but do not know how to do it.


Solution

  • mpg is a complex way to make the computer speak

    tried to use playsound its easy to install via pip and isn't so complicated. all you have to do is type in

    playsound("good.mp3")