Sapi 语音暂停错误:pywintypes.com_error:(-2147352567,“发生异常。”,(0,无,无,无,0,-2147201018),无)
我只是想制作一个 tts(将文本转换为语音)文本的应用程序,所以我发现 Sapi 语音是一个很好的库。当我在线程中运行“start_speacking”函数时,它运行良好。但是,当我暂停扬声器并等待大约 5-15 秒时,我收到以下错误...
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147201018), None)
我的代码
import threading
import time
import win32com.client
import pythoncom
speaker = win32com.client.Dispatch("SAPI.SpVoice")
def start_speaking():
global speaker
pythoncom.CoInitialize()
speaker.Speak('hello world hello world hello world')
thread = threading.Thread(target=start_speaking)
thread.start()
time.sleep(1)
speaker.Pause()
I just wnat to make an app that tts(convert text to speech) text so i found Sapi voice is a good lib for this. It works well when I run the 'start_speacking' function in a thread. BUT, when I pause the speaker and wait for about 5-15 seconds I get this error below...
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147201018), None)
my code
import threading
import time
import win32com.client
import pythoncom
speaker = win32com.client.Dispatch("SAPI.SpVoice")
def start_speaking():
global speaker
pythoncom.CoInitialize()
speaker.Speak('hello world hello world hello world')
thread = threading.Thread(target=start_speaking)
thread.start()
time.sleep(1)
speaker.Pause()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论