Raychanan / ChatGPT-for-Translation

Use Python and ChatGPT for translation. 利用Python和ChatGPT完成翻译
MIT License
392 stars 84 forks source link

Translation Stuck at last section #48

Open chenqiny opened 1 year ago

chenqiny commented 1 year ago

I encountered this issue for many times. If I am trying to translate a few document, it will stuck at last 99% percent

image

Translating paragraphs: 99%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ | 374/376 [05:02<00:01, 1.24paragraph/s] ^CTraceback (most recent call last): File "/Users/cqy/ChatGPT-for-Translation/ChatGPT-translate.py", line 115, in translate_text_file for future in tqdm(as_completed([future for idx, future in futures]), total=len(paragraphs), desc="Translating paragraphs", unit="paragraph"): File "/opt/homebrew/lib/python3.11/site-packages/tqdm/std.py", line 1182, in iter for obj in iterable: File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 243, in as_completed waiter.event.wait(wait_timeout) File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 622, in wait signaled = self._cond.wait(timeout) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 320, in wait waiter.acquire() KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/cqy/ChatGPT-for-Translation/ChatGPT-translate.py", line 309, in main() File "/Users/cqy/ChatGPT-for-Translation/ChatGPT-translate.py", line 303, in main process_folder(input_path, options) File "/Users/cqy/ChatGPT-for-Translation/ChatGPT-translate.py", line 291, in process_folder process_file(file_path, options) File "/Users/cqy/ChatGPT-for-Translation/ChatGPT-translate.py", line 272, in process_file translate_text_file(str(file_path), options) File "/Users/cqy/ChatGPT-for-Translation/ChatGPT-translate.py", line 101, in translate_text_file with ThreadPoolExecutor(max_workers=options.num_threads) as executor: File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/_base.py", line 647, in exit self.shutdown(wait=True) File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/thread.py", line 235, in shutdown t.join() File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1112, in join self._wait_for_tstate_lock() File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1132, in _wait_for_tstate_lock if lock.acquire(block, timeout): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ KeyboardInterrupt ^CException ignored in: <module 'threading' from '/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py'> Traceback (most recent call last): File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1553, in _shutdown atexit_call() File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/concurrent/futures/thread.py", line 31, in _python_exit t.join() File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1112, in join self._wait_for_tstate_lock() File "/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1132, in _wait_for_tstate_lock if lock.acquire(block, timeout): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ KeyboardInterrupt:

Raychanan commented 1 year ago

This is a great find, and I've also run into this issue occasionally. It can indeed be quite bothersome.

I suspect the problem originates from the module responsible for recognizing Chinese text prior to saving bilingual documents.

I'll definitely fix this issue.