Minty U

Implementation of ocr in 3 languages

const Tesseract = require("tesseract.js");
const Discord = require("discord.js");
exports.run = async (client, msg, args, prefix) => {
// msg.channel.send(`${client.user.username}의 핑은 ${client.ws.ping}ms 입니다!`);
if (msg.attachments.size > 0) {
if (args[0] == "한국어" || args[0] == "kor") {
msg.reply("인식중 ...");
msg.attachments.forEach(attachment => {
var ImgURL = attachment.proxyURL;
Tesseract.recognize(
ImgURL,
"kor",
{ logger: (m) => console.log(m) }
).then(({ data: { text } }) => {
// Replying with the extracted test
console.log(text);
let Commands = new Discord.MessageEmbed()
.setTitle("한국어로 문자를 인식한 결과입니다.")
.setColor("81ECEC")
.setDescription(text);
msg.reply({ embeds: [Commands] });
});
});
}
else if (args[0] == "영어" || args[0] == "eng" || !args[0]) {
msg.reply("인식중 ...");
msg.attachments.forEach(attachment => {
var ImgURL = attachment.proxyURL;
Tesseract.recognize(
......@@ -11,13 +35,50 @@ exports.run = async (client, msg, args, prefix) => {
).then(({ data: { text } }) => {
// Replying with the extracted test
console.log(text);
msg.reply(text);
let Commands = new Discord.MessageEmbed()
.setTitle("영어로 문자를 인식한 결과입니다.")
.setColor("81ECEC")
.setDescription(text);
msg.reply({ embeds: [Commands] });
});
});
}
else if (args[0] == "일본어" || args[0] == "jpn") {
msg.reply("인식중 ...");
msg.attachments.forEach(attachment => {
var ImgURL = attachment.proxyURL;
Tesseract.recognize(
ImgURL,
"jpn",
{ logger: (m) => console.log(m) }
).then(({ data: { text } }) => {
// Replying with the extracted test
console.log(text);
let Commands = new Discord.MessageEmbed()
.setTitle("일본어로 문자를 인식한 결과입니다.")
.setColor("81ECEC")
.setDescription(text);
msg.reply({ embeds: [Commands] });
});
});
}
else {
msg.reply("언어가 제대로 입력되지 않았습니다.");
}
} else {
msg.reply("이미지가 인식되지 않았습니다. 이미지를 첨부해주세요!");
}
};
function kor(attachment) {
}
exports.config = {
name: 'ocr',
aliases: ['ㅐㅊㄱ'],
......
This file is too large to display.
This file is too large to display.