def recognize_file(file_path, result_file_path, language, output_format): print("Uploading..") settings = AbbyyOnlineSdk.ProcessingSettings() settings.Language = language settings.OutputFormat = output_format task = processor.process_image(file_path, settings) if task is None: print("Error") return if task.Status == "NotEnoughCredits": print( "Not enough credits to process the document. Please add more pages to your application's account." ) return print("Id = {}".format(task.Id)) print("Status = {}".format(task.Status)) # Wait for the task to be completed print("Waiting..") # Note: it's recommended that your application waits at least 2 seconds # before making the first getTaskStatus request and also between such requests # for the same task. Making requests more often will not improve your # application performance. # Note: if your application queues several files and waits for them # it's recommended that you use listFinishedTasks instead (which is described # at https://ocrsdk.com/documentation/apireference/listFinishedTasks/). while task.is_active(): time.sleep(5) print(".") task = processor.get_task_status(task) print("Status = {}".format(task.Status)) if task.Status == "Completed": if task.DownloadUrl is not None: processor.download_result(task, result_file_path) print("Result was written to {}".format(result_file_path)) else: print("Error processing task")
# <codecell> doc_files = os.listdir(doc_dir) # <codecell> processor = abbyy.AbbyyOnlineSdk() # <codecell> processor.ApplicationId = ls.app_id processor.Password = ls.app_password # <codecell> settings = abbyy.ProcessingSettings() # <codecell> settings.Language # <codecell> settings.OutputFormat # <codecell> settings.OutputFormat = 'xml' # <codecell>