天天看点

python无效的类字符串_求助 pywintypes.com_error: (-2147221005, '无效的类字符串'... 问题...

安装了 : Speech SDK 5.1

pytts3 pywin32 安装了

python 代码就是简单的一个 tts 调用, 应该是环境的问题。。。但是不知道怎么办了, speech sdk3 找不到下载

# -*- coding: utf-8 -*-

import pythoncom

from win32com import client

pythoncom.CoInitialize()

engine=client.Dispatch("SAPI.SpVoice")

engine.Speak('hello world')

报错如下:

$ C:\Python36-32\python.exe test.py

Traceback (most recent call last):

File "C:\Python36-32\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch

IDispatch = pythoncom.connect(IDispatch)

pywintypes.com_error: (-2147221005, '无效的类字符串',

None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "test.py", line 5, in

engine=client.Dispatch("SAPI.SpVoice")

File "C:\Python36-32\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch

dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)

File "C:\Python36-32\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName

return (_GetGoodDispatch(IDispatch, clsctx), userName)

File "C:\Python36-32\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch

IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)

pywintypes.com_error: (-2147221005, '无效的类字符串',

None, None)