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
标签:文字,python,mixer,music,pygame,语音,import,order,mp3 From: https://www.cnblogs.com/fyiyy/p/17854452.html