From 4aa533ad71045042680aea40cf43c753d0bdc7b8 Mon Sep 17 00:00:00 2001 From: Caleb Fontenot Date: Fri, 9 Aug 2024 23:18:30 -0500 Subject: [PATCH] Implement OCR --- main.cjs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.cjs b/main.cjs index b491939..09476d5 100644 --- a/main.cjs +++ b/main.cjs @@ -210,13 +210,12 @@ function getMatchingPhrase(inputString, targetCharacter) { console.log(message.attachments); message.attachments.forEach(i => { if (i.contentType.includes("image")) { - //(async () => { - const worker = createWorker('eng'); - const ret = worker.recognize(i.proxyURL); - console.log("OCR Results: " + ret.data.text); - checkString = ret.data.text; - worker.terminate(); - //})(); + (async () => { + const worker = await createWorker('eng'); + const ret = await worker.recognize(i.proxyURL); + console.log("OCR Results: " + ret.data.text); + checkString = ret.data.text; + await worker.terminate(); console.log("Checking OCR contents..."); if (checkLoop(message, checkString)) { return; @@ -224,6 +223,7 @@ function getMatchingPhrase(inputString, targetCharacter) { checkString = checkString.replace(/[^a-zA-Z0-9]/g, ''); checkLoop(message, checkString); } + })(); }); } /*