File size: 619 Bytes
d69917c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from paddleocr import PaddleOCR

import translate_speak


def ocr_with_paddle(img):
    """

    Paddle OCR

    """
    try:
        finaltext = ''
        ocr = PaddleOCR(lang='en', use_angle_cls=True)
        result = ocr.ocr(img)

        for i in range(len(result[0])):
            text = result[0][i][1][0]
            finaltext += ' ' + text

        audio_path = translate_speak.audio_streaming(txt=finaltext, to=1)
        return finaltext, audio_path
    except:
        return "An err occurred upload image"

if __name__ == "__main__":
    print(ocr_with_paddle('Images/download.jpeg'))