Can't save to wav from python, can't import SpeechLib from comtypes.gen, what next?

时间秒杀一切 提交于 2019-12-24 02:37:10

问题


First the setup: Windows 8.1 64bit, Python 3.4 32bit.

I wanted to run the code here. So I installed comtypes

pip install comtypes

I then tried to run the code, i got

ImportError: cannot import name 'SpeechLib'

Then tried this code here to try and generate the needed SpeechLib module.

I am however still getting the same error, what should I try next?


回答1:


Running these lines made it work:

from comtypes.client import CreateObject
engine = CreateObject("SAPI.SpVoice")
stream = CreateObject("SAPI.SpFileStream")

Output was:

# Generating comtypes.gen._C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4
# Generating comtypes.gen.SpeechLib

After this I got no import error anymore, as expected.



来源:https://stackoverflow.com/questions/28851423/cant-save-to-wav-from-python-cant-import-speechlib-from-comtypes-gen-what-ne

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!