如何让电脑用python说话?

How to make the computer speak in python?

我尝试使用 gtts:

from gtts import gTTs
import os

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

但是我得到了这个错误:

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

为什么会这样?我什至有portaudio但不知道怎么做。

mpg 是一种让计算机说话的复杂方法

尝试使用 playsound,它很容易通过 pip 安装,而且并不复杂。 您所要做的就是输入

playsound("good.mp3")