Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当在没有控制台的情况下运行时,Python从语音识别模块识别google失败_Python_Console_Speech Recognition_Pyinstaller_Speech To Text - Fatal编程技术网

当在没有控制台的情况下运行时,Python从语音识别模块识别google失败

当在没有控制台的情况下运行时,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

当使用控制台运行时,模块工作正常,没有错误,但使用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 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中工作。如果有帮助,它会先冻结,然后崩溃