利用python将文本文件转换成mp3--听书
from comtypes.client import CreateObject from comtypes.gen import SpeechLib engine = CreateObject("SAPI.SpVoice") stream = CreateObject("SAPI.SpFileStream") infile = "SHIVA.txt" outfile = "三体.mp3" stream.Open(outfile, SpeechLib.SSFMCreateForWrite) engine.AudioOutputStream = stream f = open(infile, 'r',encoding='utf-8') theText = f.read() f.close() engine.speak(theText) stream.Close()