SpeechRecognition库中的Pyinstaller noconsole /窗口问题

时间:2019-02-02 17:20:37

标签: python python-3.x speech-recognition pyinstaller

我的系统:Windows 10 64位,Python 3.5.4,pip 9.0.1

我的代码:

#. Tkinter codes
#.........................
#.........................
def main():
    r = sr.Recognizer()
    with sr.Microphone() as source:
        status.set("Listening...") #Tkinter Label
        sound = r.listen(ses_kaynagi)
    try:
        status.set("Processing...") #Tkinter Label
        word=r.recognize_google(sound, language="tr-tr")
        print(word)
    except:
        pass

while True:
    keyboard.add_hotkey('ctrl+alt', main) #Keyboard Library

我用PyInstaller(pyinstaller.exe --onefile)冻结了代码,一切正常。但是当我隐藏控制台(pyinstaller.exe --onefile --noconsole或--windowed)时,我的代码输入了except块。因此word=r.recognize_google(sound, language="tr-tr")无法正常工作。

0 个答案:

没有答案