当在没有控制台的情况下运行时,Python从语音识别模块识别google失败
当使用控制台运行时,模块工作正常,没有错误,但使用Pyinstaller将其转换为无控制台可执行文件会使我的程序崩溃。它一直工作到当在没有控制台的情况下运行时,Python从语音识别模块识别google失败,python,console,speech-recognition,pyinstaller,speech-to-text,Python,Console,Speech Recognition,Pyinstaller,Speech To Text,当使用控制台运行时,模块工作正常,没有错误,但使用Pyinstaller将其转换为无控制台可执行文件会使我的程序崩溃。它一直工作到recognize\u google()函数。这是完整的代码: import speech_recognition as sr import autopy3 import ctypes import winsound from winsound import * upali = sr.Recognizer() def slusaj(): print("Cekam
recognize\u google()
函数。这是完整的代码:
import speech_recognition as sr
import autopy3
import ctypes
import winsound
from winsound import *
upali = sr.Recognizer()
def slusaj():
print("Cekam naredbu...")
with sr.Microphone() as glas:
zvuk = upali.listen(glas)
winsound.Beep(670,400)
try:
#naredba = upali.recognize_google(zvuk)
winsound.Beep(270,400)
except:
slusaj()
#try:
winsound.Beep(870,400)
#naredba = upali.recognize_google(zvuk)
print("Rekao si: "+ upali.recognize_google(zvuk))
winsound.Beep(1000,800)
#if naredba == "Lock" or "lock":
# ctypes.windll.user32.LockWorkStation()
if upali.recognize_google(zvuk) == "lock":
#winsound.Beep(670,400)
ctypes.windll.user32.LockWorkStation()
else:
slusaj()
#except:
#slusaj()
slusaj()
什么是撞车?发布回溯。这就是问题所在,我看不出来,因为它只有在没有控制台的情况下才会崩溃,它在pythonwin和idle中工作。如果有帮助,它会先冻结,然后崩溃。什么是崩溃?发布回溯。这就是问题所在,我看不出来,因为它只有在没有控制台的情况下才会崩溃,它在pythonwin和idle中工作。如果有帮助,它会先冻结,然后崩溃