如何对程序进行多线程处理并将结果返回到 main.py?

问题描述

我使用的是 Windows 和 Python。目标很简单,运行 Button_Click(object sender,RoutedEventArgs e) 会启动语音识别,一旦它识别出所说的内容,就将文本返回到 main.py。语音识别程序识别没有任何问题,问题在于多线程并将结果返回到 main.py

这里是main.py:

main.py

这里是语音识别,它被称为一个新线程:

import threading
from speechEngine.recognize import *
from SpeechSynthesis.speech import *
from core.AI import *
spch= "default"
newthread=threading.Thread(target=speechrec())
newthread.start()
while(True):
    if(spch == "default"):
        print("at default")
        continue
    else:
        print(spch)
        result=process(spch)
        speak(result)
        spch="default"

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)