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

Posted MrSimple0

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了利用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--听书的主要内容,如果未能解决你的问题,请参考以下文章