Dee*_*rma 6 python audio mp3 text-to-speech
我可以使用puttsx在python中将文本转换为语音.我可以使用麦克风(耳机)录制音频到mp3文件.
我想要做的是将文本转换为mp3文件.
有没有办法将使用pyttsx播放的音频存储到内存或unicode字符串.
任何人都可以帮助我将音频存储到内存,或者如何将该字符串转换为mp3文件.
要从文本文件生成音频文件,我正在使用此代码,希望它可以帮助您
from comtypes.client import CreateObject
engine = CreateObject("SAPI.SpVoice")
stream = CreateObject("SAPI.SpFileStream")
from comtypes.gen import SpeechLib
infile = "SHIVA.txt"
outfile = "SHIVA-audio.wav"
stream.Open(outfile, SpeechLib.SSFMCreateForWrite)
engine.AudioOutputStream = stream
f = open(infile, 'r')
theText = f.read()
f.close()
engine.speak(theText)
stream.Close()
Run Code Online (Sandbox Code Playgroud)