tesseract.js icon indicating copy to clipboard operation
tesseract.js copied to clipboard

Stuck on "loading language traineddata"

Open chukwumaijem opened this issue 5 years ago • 1 comments

Describe the bug I have a simple html with script tags as follows.

  <script src='https://unpkg.com/[email protected]/dist/tesseract.min.js'></script>
  <script>
    window.onload = async () => {
      const worker = Tesseract.createWorker({
        logger: m => console.log(m)
      });

      await worker.load();
      await worker.loadLanguage('eng');
      await worker.initialize('eng');
      const recData = await worker.recognize('https://tesseract.projectnaptha.com/img/eng_bw.png');

      console.log('=====recData===', recData);
      await worker.terminate();
    }
  </script>

When the page loads, i the following logs on the console, and nothing else happens. What am I doing wrong? Screenshot 2020-04-14 at 07 49 48

Environment

  • OS: MacOS Catalina
  • Browser [e.g. chrome version 80]

chukwumaijem avatar Apr 14 '20 06:04 chukwumaijem

Most of the time it is a network issue.

You can try to use the offline version first and see if it works: https://github.com/jeromewu/tesseract.js-offline

jeromewu avatar Apr 26 '20 06:04 jeromewu

adding cachemethod: 'none' in worker constructor solved this issue for me. loading data and workers from CDN is really the worst design choice in this wrapper.

0687a4 avatar Sep 05 '22 22:09 0687a4

Closed as duplicate of #414. I will look into why the promise returned by loadLanguage never resolves, and post findings on that issue.

Balearica avatar Sep 20 '22 05:09 Balearica