【发布时间】:2021-09-06 15:48:37
【问题描述】:
所以我使用由一个窗口和一个按钮组成的 tkinter,当我按下监听按钮时它开始没有响应?这是我的代码
import speech_recognition as sr
import tkinter as tk
from tkinter import *
def listen():
listener = sr.Recognizer()
try:
with sr.Microphone() as source:
print("Listening...")
voice = listener.listen(source)
command = listener.recognize_google(voice)
# command = command.lower()
# if 'bot' in command1:
# command1 = command1.replace('bot', '')
print(command)
except:
print("not working")
pass
def stop():
pass
form = tk.Tk()
form.geometry('1200x600')
buttonListen = Button(form, text='listen',command=listen)
buttonListen.pack()
form.mainloop()
这是我的代码,谁能帮帮我?
【问题讨论】:
标签: python tkinter speech-recognition