def __init__(self, master):
global APP_INSTANCE
APP_INSTANCE = self
self.top = master
self.index = 0
# display first image
filename = "images/alphabet6.jpg"
if not os.path.exists(filename):
print "Unable to find %s" % filename
self.top.quit()
im = Image.open(filename)
im = im.resize((self.top.winfo_screenwidth(), self.top.winfo_screenheight()))
if im.format == "SPIDER":
im = im.convert2byte()
self.size = im.size
self.tkimage = ImageTk.PhotoImage(im)
self.lbl = Label(master, image=self.tkimage)
self.lbl.pack(side="top")
r = sr.Recognizer()
m = sr.Microphone()
with m as source:
r.adjust_for_ambient_noise(source)
self.stop_listening = r.listen_in_background(m, callback)
# image doesn't appear unless put Image.open in separate function?
# and need to use tkimage.paste, not ImageTk.PhotoImage
评论列表
文章目录