Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import easyocr
|
| 3 |
-
from
|
| 4 |
from PIL import Image, ImageDraw, ImageFont
|
| 5 |
import numpy as np
|
| 6 |
import cv2
|
|
@@ -8,8 +8,7 @@ import cv2
|
|
| 8 |
# Load OCR reader
|
| 9 |
reader = easyocr.Reader(['en', 'hi'])
|
| 10 |
|
| 11 |
-
|
| 12 |
-
translator = Translator()
|
| 13 |
|
| 14 |
def translate_image(image, src_lang, tgt_lang):
|
| 15 |
# Convert PIL Image to OpenCV format
|
|
@@ -28,7 +27,7 @@ def translate_image(image, src_lang, tgt_lang):
|
|
| 28 |
for (bbox, text, prob) in results:
|
| 29 |
# Translate text
|
| 30 |
try:
|
| 31 |
-
translated =
|
| 32 |
except:
|
| 33 |
translated = text # fallback
|
| 34 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import easyocr
|
| 3 |
+
from deep_translator import GoogleTranslator
|
| 4 |
from PIL import Image, ImageDraw, ImageFont
|
| 5 |
import numpy as np
|
| 6 |
import cv2
|
|
|
|
| 8 |
# Load OCR reader
|
| 9 |
reader = easyocr.Reader(['en', 'hi'])
|
| 10 |
|
| 11 |
+
|
|
|
|
| 12 |
|
| 13 |
def translate_image(image, src_lang, tgt_lang):
|
| 14 |
# Convert PIL Image to OpenCV format
|
|
|
|
| 27 |
for (bbox, text, prob) in results:
|
| 28 |
# Translate text
|
| 29 |
try:
|
| 30 |
+
translated = GoogleTranslator(source='auto', target='hi').translate("Hello")
|
| 31 |
except:
|
| 32 |
translated = text # fallback
|
| 33 |
|