Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest tesseract then V8 platform used by this instance of Node does not support creating Workers #756

Closed
hayr-hotoca opened this issue May 10, 2023 · 7 comments

Comments

@hayr-hotoca
Copy link

hayr-hotoca commented May 10, 2023

Tesseract.js version (version number for npm/GitHub release, or specific commit for repo)
v4.0.5

Describe the bug
On tesseract v2.1.5 everything works correctly. Once updated to v4.0.5 this error happens.

Screenshot 2023-05-10 at 21 58 33

To Reproduce
Steps to reproduce the behavior:

Try this code:

const worker = await createWorker({
  logger: m => console.log(m)
});

Expected behavior
Latest version should work without error just like the v2.1.5 version.

Device Version:

  • OS + Version: Macbook Pro 14 2021 + MacOS 13
  • ElectronJS v21.4.4, NodeJS v14.16.1
@Balearica
Copy link
Member

Balearica commented May 10, 2023

Tesseract.js is confirmed to work with Node 14 (we have unit tests for this), so your steps to reproduce will not create any error. Please provide enough code to reproduce the error. You can also link to a repository with a minimal example.

Also, it does not look like Node v14.6.1 exists.

@Balearica
Copy link
Member

It sounds like you are trying to use the Node version of Tesseract.js for Electron, which will not work. You should use the browser version of Tesseract.js.

@hayr-hotoca
Copy link
Author

hayr-hotoca commented May 12, 2023

I'm thinking of using the browser version.

Can I set a local lang traineddata path like the node version?

I don't see the doc and example having it specified.

@Balearica
Copy link
Member

For the browser version, to avoid using any remote CDN you would need to specify langPath, workerPath, and corePath. This is explained here. This is different from the Node version where you only need to specify langPath (as Tesseract.js-core is automatically installed by npm and all code is run from node_modules).

In general, the browser version will not have direct access to the local filesystem (this is true of all browser-based code), so running the browser examples locally still requires using a local http server. I have not used Electron personally, so am not immediately sure what that would look like within an Electron context.

@Balearica
Copy link
Member

Thinking about this more, presumably to have everything local in Electron it would be read from the local filesystem from some Electron-provided function, and then passed to Tesseract.js as an arraybuffer. Let me know if that sounds right. I would need to think about whether that is currently possible or if it would require an update to Tesseract.js.

@Balearica
Copy link
Member

@lincdh I found it was possible to use Tesseract.js fully offline (including local .traineddata) in Electron. I added an example to this repo.

@Balearica
Copy link
Member

Closing as completed, as a fully offline example of Tesseract.js v4.0.5 running on Electron has been provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants