pip install pygame
pip install gtts
import os import pygame from gtts import gTTS text = "你有新的美团外卖订单,请注意查收!" tts = gTTS(text, lang='zh', slow=False, ) tts.save("./order.mp3") # os.system("start ./order.mp3") file = './order.mp3' pygame.mixer.init() pygame.mixer.music.load(file) pygame.mixer.music.play() while pygame.mixer.music.get_busy(): continue