【发布时间】:2018-09-27 00:23:13
【问题描述】:
我正在尝试将文本到语音的结果保存到 Windows 上的文件中。我成功地让它说话(使用speak.Speak)。但是,保存文件就没有这样的运气了。
问题是没有找到AudioOutputStream,尽管它是being listed in the Microsoft docs。
版本信息:Windows 10、Python 3.6
错误
Traceback (most recent call last):
File "...\dd.py", line 87, in <module>
speak.AudioOutputStream = filestream
File "...\win32com\client\dynamic.py", line 565, in __setattr__
self._oleobj_.Invoke(entry.dispid, 0, invoke_type, 0, value)
pywintypes.com_error: (-2147352573, 'Member not found.', None, None)
代码
from win32com.client import Dispatch
import win32api
speak = Dispatch("SAPI.SpVoice")
filestream = Dispatch("SAPI.SpFileStream")
filestream.open("out.wav", 3, False)
for k in speak.GetAudioOutputs():
print(k.GetDescription())
speak.AudioOutputStream = filestream
speak.Speak("test")
filestream.close()
【问题讨论】:
标签: python text-to-speech