pyttsx3在说话时tkinter文本

发布于 2025-01-25 06:32:19 字数 768 浏览 6 评论 0原文

我想要同步的pyttsx3和tkinter-text。我的意思是,我想看看我在字幕之类的文字中讲的是 但是我无法处理。当它不在一段时间内循环时。你们是否知道如何在循环循环中同步进行同步?感谢您的帮助。

       with sr.Microphone() as source:
            while True:
                r.adjust_for_ambient_noise(source, duration=1)

                voice = r.listen(source)
                text_punk = r.recognize_google(voice, language="en-US")
                text_punk = text_punk.lower()
                punk_screen = "You---> " + text_punk
                txt.insert(END, "\n" + punk_screen)

                

                if text_punk != '':
                    test=testpy.Testing()
                    res = test.response(text_punk)
                    txt.insert(END, "\n" + 'Bot---> ' + res)
                    talk(res)

I want pyttsx3 and tkinter-text go synchronically. I mean, I want to see what I told in a text like the subtitles
However I could not manage that. It is possible when it is not in a while loop.... but when I use it in while loop it shows the the whole dialogue after the speech is done. Do you guys have any idea how to make them go synchronically when in a while loop? Thank you for your help.

       with sr.Microphone() as source:
            while True:
                r.adjust_for_ambient_noise(source, duration=1)

                voice = r.listen(source)
                text_punk = r.recognize_google(voice, language="en-US")
                text_punk = text_punk.lower()
                punk_screen = "You---> " + text_punk
                txt.insert(END, "\n" + punk_screen)

                

                if text_punk != '':
                    test=testpy.Testing()
                    res = test.response(text_punk)
                    txt.insert(END, "\n" + 'Bot---> ' + res)
                    talk(res)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

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