Fix small images with Azure and error messages being copied out

This commit is contained in:
AuroraWright
2024-02-06 12:11:43 +01:00
parent d69a1df6ec
commit cec8f3adc9
2 changed files with 21 additions and 12 deletions

View File

@@ -308,21 +308,21 @@ def process_and_write_results(engine_instance, img_or_path, write_to, enable_fil
notification.title = 'Text recognized:'
notification.message = text
notification.send(block=False)
if write_to == 'websocket':
websocket_server_thread.send_text(text)
elif write_to == 'clipboard':
pyperclipfix.copy(text)
else:
write_to = Path(write_to)
if write_to.suffix.lower() != '.txt':
raise ValueError('write_to must be either "websocket", "clipboard" or a path to a text file')
with write_to.open('a', encoding='utf-8') as f:
f.write(text + '\n')
else:
logger.opt(ansi=True).info(f'<{engine_color}>{engine_instance.readable_name}</{engine_color}> reported an error after {t1 - t0:0.03f}s: {text}')
if write_to == 'websocket':
websocket_server_thread.send_text(text)
elif write_to == 'clipboard':
pyperclipfix.copy(text)
else:
write_to = Path(write_to)
if write_to.suffix.lower() != '.txt':
raise ValueError('write_to must be either "websocket", "clipboard" or a path to a text file')
with write_to.open('a', encoding='utf-8') as f:
f.write(text + '\n')
return orig_text