@xuda.io/drive_module 1.1.953 → 1.1.955
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +17 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1727,7 +1727,15 @@ const ocr_drive_file = async function (app_id, doc) {
|
|
|
1727
1727
|
|
|
1728
1728
|
switch (doc.mime.split("/")[0]) {
|
|
1729
1729
|
case "image": {
|
|
1730
|
-
|
|
1730
|
+
const initialText = await tesseract.recognize(
|
|
1731
|
+
target_file,
|
|
1732
|
+
generalConfig
|
|
1733
|
+
);
|
|
1734
|
+
|
|
1735
|
+
// Detect the language from the extracted text
|
|
1736
|
+
const detectedLang = franc(initialText);
|
|
1737
|
+
const tesseractLang = detectedLang || "eng";
|
|
1738
|
+
ocr = await tesseract.recognize(target_file, tesseractLang);
|
|
1731
1739
|
|
|
1732
1740
|
break;
|
|
1733
1741
|
}
|
|
@@ -1739,7 +1747,14 @@ const ocr_drive_file = async function (app_id, doc) {
|
|
|
1739
1747
|
|
|
1740
1748
|
const images = await convertPDF(target_file);
|
|
1741
1749
|
for await (const imageData of images) {
|
|
1742
|
-
|
|
1750
|
+
const initialText = await tesseract.recognize(
|
|
1751
|
+
imageData.path,
|
|
1752
|
+
generalConfig
|
|
1753
|
+
);
|
|
1754
|
+
|
|
1755
|
+
// Detect the language from the extracted text
|
|
1756
|
+
const detectedLang = franc(initialText);
|
|
1757
|
+
ocr += await tesseract.recognize(imageData.path, tesseractLang);
|
|
1743
1758
|
}
|
|
1744
1759
|
break;
|
|
1745
1760
|
}
|