File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ def translate_cn(input_file):
8585 file .write ("" )
8686
8787 for i , chunk in enumerate (chunks ):
88- max_retries = 1
88+ max_retries = 2
8989 retry_count = 0
9090
9191 while retry_count < max_retries :
@@ -113,7 +113,7 @@ def translate_cn(input_file):
113113
114114 # Append this chunk's translation to the output file immediately
115115 with open (output_file , 'a' , encoding = 'utf-8' ) as file :
116- file .write (response_text + "\n " )
116+ file .write (response_text + "\n \n " ) # Add an extra newline for spacing between chunks
117117
118118 logging .info (f"Wrote chunk { i + 1 } translation to { output_file } " )
119119 break # Success, exit retry loop
@@ -131,7 +131,7 @@ def translate_cn(input_file):
131131
132132if __name__ == "__main__" :
133133 directory = "lectures"
134- max_workers = 3 # Adjust this based on your API rate limits and system capabilities
134+ max_workers = 2 # Adjust this based on your API rate limits and system capabilities
135135
136136 files = [f for f in os .listdir (directory ) if f .endswith ('.md' ) and os .path .isfile (os .path .join (directory , f ))]
137137 logging .info (f'Files to translate: { files } ' )
You can’t perform that action at this time.
0 commit comments