Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,17 +4,20 @@ from gtts import gTTS
|
|
| 4 |
import pytesseract
|
| 5 |
import tempfile
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
def bangla_reader(image):
|
| 8 |
if image is None:
|
| 9 |
return "কোনো ছবি দেওয়া হয়নি।", None
|
| 10 |
-
|
| 11 |
-
#
|
| 12 |
ocr_text = pytesseract.image_to_string(image, lang='ben')
|
| 13 |
-
|
| 14 |
if not ocr_text.strip():
|
| 15 |
return "কোনো লেখা সনাক্ত করা যায়নি।", None
|
| 16 |
-
|
| 17 |
-
#
|
| 18 |
try:
|
| 19 |
tts = gTTS(text=ocr_text, lang='bn')
|
| 20 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp:
|
|
|
|
| 4 |
import pytesseract
|
| 5 |
import tempfile
|
| 6 |
|
| 7 |
+
# FIX: Set Tesseract path explicitly
|
| 8 |
+
pytesseract.pytesseract.tesseract_cmd = '/usr/bin/tesseract'
|
| 9 |
+
|
| 10 |
def bangla_reader(image):
|
| 11 |
if image is None:
|
| 12 |
return "কোনো ছবি দেওয়া হয়নি।", None
|
| 13 |
+
|
| 14 |
+
# OCR with Bengali support
|
| 15 |
ocr_text = pytesseract.image_to_string(image, lang='ben')
|
| 16 |
+
|
| 17 |
if not ocr_text.strip():
|
| 18 |
return "কোনো লেখা সনাক্ত করা যায়নি।", None
|
| 19 |
+
|
| 20 |
+
# Text-to-Speech
|
| 21 |
try:
|
| 22 |
tts = gTTS(text=ocr_text, lang='bn')
|
| 23 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp:
|