You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<script src="/dist/tesseract.dev.js"></script>
|
|
</head>
|
|
<body>
|
|
<input type="file" id="uploader">
|
|
<script>
|
|
const recognize = function(evt){
|
|
const files = evt.target.files;
|
|
const worker = Tesseract.createWorker({
|
|
/*
|
|
* As Edge don't support webassembly,
|
|
* here we force to use asm.js version.
|
|
*/
|
|
corePath: '../../node_modules/tesseract.js-core/tesseract-core.asm.js',
|
|
logger: function(m){console.log(m);},
|
|
/*
|
|
* As there is no indexedDB in earlier version
|
|
* of Edge, here we disable cache.
|
|
*/
|
|
cacheMethod: 'none',
|
|
});
|
|
Promise.resolve()
|
|
.then(() => worker.load())
|
|
.then(() => worker.loadLanguage('eng'))
|
|
.then(() => worker.initialize('eng'))
|
|
.then(() => worker.recognize(files[0]))
|
|
.then((ret) => {
|
|
console.log(ret.data.text);
|
|
});
|
|
}
|
|
const elm = document.getElementById('uploader');
|
|
elm.addEventListener('change', recognize);
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|