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

worker.load is not a function #49

Open
20b01a12b4 opened this issue Nov 18, 2023 · 0 comments
Open

worker.load is not a function #49

20b01a12b4 opened this issue Nov 18, 2023 · 0 comments

Comments

@20b01a12b4
Copy link

This is my App.js code when iam trying to run this iam getting this error "worker.load is not a fuction"!!

please resolve this !!

`import { useCallback, useEffect, useState } from 'react';
import { createWorker } from 'tesseract.js';
import './App.css';

function App() {
const [selectedImage, setSelectedImage] = useState(null);
const [textResult, setTextResult] = useState("");

const worker = createWorker();

const convertImageToText = useCallback(async () => {
if(!selectedImage) return;
await worker.load();
await worker.loadLanguage("eng");
await worker.initialize("eng");
const { data } = await worker.recognize(selectedImage);
console.log(data)
setTextResult(data.text);
}, [worker, selectedImage]);

useEffect(() => {
convertImageToText();
}, [selectedImage, convertImageToText])

const handleChangeImage = e => {
if(e.target.files[0]) {
setSelectedImage(e.target.files[0]);
} else {
setSelectedImage(null);
setTextResult("")
}
}
return (


Image to Text


Get words from image !!



upload image

  <div className='result'>
    {selectedImage && (
      <div className='box-image'>
        <img src={URL.createObjectURL(selectedImage)} alt="thumb" />
      </div>
    )}
    {textResult && (
      <div className='box-p'>
        <p>{textResult}</p>
        </div>
    )}
  </div>
</div>

);
}

export default App;`

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

1 participant