botbahlul / autosrt

A python script COMMAND LINE utility to AUTO GENERATE SUBTITLE FILE (using free Google Speech Recognition API) and TRANSLATED SUBTITLE FILE (using unofficial online Google Translate API) for any video or audio file
MIT License
48 stars 11 forks source link

read operation time out #3

Closed tiantianaixuexi closed 1 year ago

tiantianaixuexi commented 1 year ago

hello , i want to generate English to Chinese. it can complete Engilsh . but Convert Engilsh to Chines it show this error. can you help me?

ultiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "C:\Python311\Lib\site-packages\httpcore_exceptions.py", line 10, in map_exceptions yield File "C:\Python311\Lib\site-packages\httpcore\backends\sync.py", line 28, in read return self._sock.recv(max_bytes) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\ssl.py", line 1263, in recv return self.read(buflen) ^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\ssl.py", line 1136, in read return self._sslobj.read(len) ^^^^^^^^^^^^^^^^^^^^^^ TimeoutError: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Python311\Lib\site-packages\httpx_transports\default.py", line 60, in map_httpcore_exceptions yield File "C:\Python311\Lib\site-packages\httpx_transports\default.py", line 218, in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpcore_sync\connection_pool.py", line 253, in handle_request raise exc File "C:\Python311\Lib\site-packages\httpcore_sync\connection_pool.py", line 237, in handle_request response = connection.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpcore_sync\http_proxy.py", line 316, in handle_request return self._connection.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpcore_sync\http2.py", line 144, in handle_request raise exc File "C:\Python311\Lib\site-packages\httpcore_sync\http2.py", line 112, in handle_request status, headers = self._receive_response( ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpcore_sync\http2.py", line 229, in _receive_response event = self._receive_stream_event(request, stream_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpcore_sync\http2.py", line 260, in _receive_stream_event self._receive_events(request, stream_id) File "C:\Python311\Lib\site-packages\httpcore_sync\http2.py", line 281, in _receive_events events = self._read_incoming_data(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpcore_sync\http2.py", line 341, in _read_incoming_data raise exc File "C:\Python311\Lib\site-packages\httpcore_sync\http2.py", line 327, in _read_incoming_data data = self._network_stream.read(self.READ_NUM_BYTES, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpcore\backends\sync.py", line 26, in read with map_exceptions(exc_map): File "C:\Python311\Lib\contextlib.py", line 155, in exit self.gen.throw(typ, value, traceback) File "C:\Python311\Lib\site-packages\httpcore_exceptions.py", line 14, in map_exceptions raise to_exc(exc) httpcore.ReadTimeout: The read operation timed out

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Python311\Lib\multiprocessing\pool.py", line 125, in worker result = (True, func(*args, **kwds)) ^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\autosrt__init.py", line 458, in call translated_sentence = GoogleTranslate(sentence, src=self.src, dst=self.dest) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\autosrt__init__.py", line 431, in GoogleTranslate response = client.get(url+params) ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpx_client.py", line 1045, in get return self.request( ^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpx_client.py", line 821, in request return self.send(request, auth=auth, follow_redirects=follow_redirects) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpx_client.py", line 908, in send response = self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpx_client.py", line 936, in _send_handling_auth response = self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpx_client.py", line 973, in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpx_client.py", line 1009, in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\httpx_transports\default.py", line 217, in handle_request with map_httpcore_exceptions(): File "C:\Python311\Lib\contextlib.py", line 155, in exit__ self.gen.throw(typ, value, traceback) File "C:\Python311\Lib\site-packages\httpx_transports\default.py", line 77, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ReadTimeout: The read operation timed out """

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Python311\Scripts\autosrt-script.py", line 33, in sys.exit(load_entry_point('autosrt==1.1.1', 'console_scripts', 'autosrt')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python311\Lib\site-packages\autosrt__init__.py", line 711, in main for i, translated_subtitle in enumerate(pool.imap(transcript_translator, created_subtitles)): File "C:\Python311\Lib\multiprocessing\pool.py", line 873, in next raise value

tiantianaixuexi commented 1 year ago

autosrt -S en -D zh-CN ".\3 - Aspen Tree Branch Texture Part1.mp4" this is my cmd

botbahlul commented 1 year ago

It's working fine here. It seems that if the traffic is to high, that translate server will respond with time out operation. But it seems happened occasionally. You can try to reduce the concurrency value to lower than 10, e.g.

autosrt -C 8 -S en -D zh-CN ".\3 - Aspen Tree Branch Texture Part1.mp4"

I've switched GoogleTranslate function to use requests module instead of httpx. It seems more reliable now.

botbahlul commented 1 year ago

ONE MORE THING, IF ALL GOOGLE SERVERS HAS BEEN BANNED BY YOUR ISP, YOU SHOULD USE VPN!

tiantianaixuexi commented 1 year ago

Thank you ,i will try.