listen.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:StrangerThings_LightWall 作者: bwall 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号