利用python将文本文件转换成mp3--听书

黄沙百战穿金甲,不破楼兰终不还。这篇文章主要讲述利用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()

 
搜索
复制
【利用python将文本文件转换成mp3--听书】


    推荐阅读