Sapi 语音暂停错误:pywintypes.com_error:(-2147352567,“发生异常。”,(0,无,无,无,0,-2147201018),无)

发布于 2025-01-15 06:15:47 字数 676 浏览 2 评论 0原文

我只是想制作一个 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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文