__init__.py 文件源码

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

项目:Nightchord 作者: theriley106 项目源码 文件源码
def genNC(image=None, listofwords=[], artist=None, song=None):
    threads = []
    Words = {}

    def batchExtract(listofimages):
        for image in listofimages:
            try:
                extractText(image)
            except Exception as exp:
                print(exp)
                pass

    def doCommand(image, listofwords):
        a = pytesseract.image_to_string(Image.open(image)).encode('utf-8','replace').split(' ')
        for a in a:
            if len(a) > 3:
                print difflib.get_close_matches(str(a), listofwords)[0]

    Information = {}
    listofwords = GrabSongLyrics(artist, song)
    d = []

    for i in range(len(image) / 5):
        t = threading.Thread(target=batchExtract, args=([image[i*5:(i*5) + 4]]))
        d.append(t)
        t.start()

    for t in d:
        t.join()

    for i, image in enumerate(image):
        t = threading.Thread(target=doCommand, args=(image, i))
        threads.append(t)
        t.start()

    for t in threads:
        t.join()
    Information["GuessedWords"] = Words
    Information["Real_Lyrics"] = listofwords
    with open('{}Transcript.json'.format(Words[1]), 'w') as f:
        json.dump(Information, f)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号