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

Cannot run worker on electron renderer process #696

Closed
vuggy17 opened this issue Dec 7, 2022 · 2 comments
Closed

Cannot run worker on electron renderer process #696

vuggy17 opened this issue Dec 7, 2022 · 2 comments

Comments

@vuggy17
Copy link

vuggy17 commented Dec 7, 2022

I'm using react-electron-boilerplate and install tesseract by yarn add tesseract.js . Then I create a worker like snippet bellow, and it doesn't work, but when I move it to main process, it work

  • Expected: tesseract run on renderer process
  • Actually: tesseract run on main process only

main.ts

ipcMain.on('translate', async (event, args) => {
  const worker = createWorker();
  await worker.load();
  await worker.loadLanguage('eng');
  await worker.initialize('eng');
  const { data } = await worker.recognize(
    path.join(__dirname, '../../assets/icons/eng_bw.png')
  );
console.log(text)
});

App.ts

 const start = async () => {
    const worker = createWorker();
    await worker.load();

    await worker.loadLanguage('eng');
    await worker.initialize('eng');
    const { data } = await worker.recognize('../../assets/icons/eng_bw.png');
    console.log(data);
  };

start() // won't work

Bonus: I'm trying to implement realtime translate (video translate) and I need to do OCR stuff on renderer process.

Does anyone know a work around or something?

@Balearica
Copy link
Collaborator

Can you create a repo that I can clone to replicate the error? I have virtually no experience with Electron, but can look into this given that Electron-related issues have been raised several times.

@Balearica
Copy link
Collaborator

Closing as stale. If other users have this problem, please open a new issue with a reproducible example repo. Code snippets really only work as reprex when they can be copy/pasted in any browser, not when they require additional code to run.

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