7
7
router = APIRouter ()
8
8
9
9
def pdf_to_images (pdf_path , output_folder ):
10
+
10
11
# Convert PDF pages to images
11
12
images = convert_from_path (pdf_path )
12
13
@@ -20,8 +21,7 @@ def pdf_to_images(pdf_path, output_folder):
20
21
image_path = os .path .join (output_folder , f'page_{ i + 1 } .jpeg' )
21
22
image .save (image_path , 'JPEG' )
22
23
image_paths .append (image_path )
23
- noImg = i + 1
24
-
24
+ noImg = i + 1
25
25
return image_paths ,noImg
26
26
27
27
@router .get ("/NotesToText" )
@@ -35,6 +35,7 @@ def NotesToText_handler():
35
35
# Convert the PDF to images and save them in the output folder
36
36
image_paths , noImg = pdf_to_images (pdf_path , output_folder )
37
37
print (noImg )
38
+
38
39
os .environ ['GOOGLE_APPLICATION_CREDENTIALS' ] = 'Files/client_file_vision.json'
39
40
client = vision .ImageAnnotatorClient ()
40
41
@@ -58,11 +59,11 @@ def NotesToText_handler():
58
59
file .write (image_contents )
59
60
print (f"module-{ i + 1 } completed" )
60
61
61
- if response .error .message :
62
- raise Exception (
63
- '{}\n For more info on error messages, check: '
64
- 'https://cloud.google.com/apis/design/errors' .format (
65
- response .error .message ))
62
+ if response .error .message :
63
+ raise Exception (
64
+ '{}\n For more info on error messages, check: '
65
+ 'https://cloud.google.com/apis/design/errors' .format (
66
+ response .error .message ))
66
67
67
68
68
69
0 commit comments