簡體   English   中英

我已經使用此代碼通過 pyttx3 進行文本到語音的轉換,但出現此錯誤我不知道如何解決

[英]I have used this code for text to speech via pyttx3 and get this error I dont know how to solve it

import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait() 

錯誤:

return __import__(fullname, globals(), locals(), ['DUMMY'])
  File "C:\Users\Karan\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\gen\_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py", line 1863, in <module>
    ISpeechWaveFormatEx._methods_ = [
  File "C:\Users\Karan\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\__init__.py", line 329, in __setattr__
    self._make_methods(value)
  File "C:\Users\Karan\AppData\Local\Programs\Python\Python38\lib\site-packages\comtypes\__init__.py", line 698, in _make_methods
    prototype = WINFUNCTYPE(restype, *argtypes)
  File "C:\Users\Karan\AppData\Local\Programs\Python\Python38\lib\ctypes\__init__.py", line 125, in WINFUNCTYPE
    class WinFunctionType(_CFuncPtr):
TypeError: item 1 in _argtypes_ passes a union by value, which is unsupported.

只需使用降級 python 版本,如 3.8.0 或之前

pip uninstall pyttsx3
pip install pyttsx3==2.6

您可以使用“pip install pyttsx3==2.71”安裝 pyttsx3。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM