语言识别模块中的Python recogn_google在没有控制台的情况下运行时失败

时间:2016-01-13 16:54:10

标签: python console speech-recognition pyinstaller speech-to-text

当使用控制台运行时,模块正常工作没有错误,但使用Pyinstaller将其转换为无控制台可执行文件会导致程序崩溃。它一直有效recognize_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()

0 个答案:

没有答案