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)
评论列表
文章目录