>>102678403
So I asked Codestral to write two scripts, one removes all timing lines from the .srt file and saves them to a separate file, the other restores them to the original file. After running the first one, I translate the cleaned up script with Qwen, paste the results back into the .srt and run the second one. Here they are
Save as srt_timing_cut.py, then run python srt_timing_cut.py
import os
# Input file name
input_file = r"w:\subs\ようちえん戦隊げんきっず 13.srt"
# Output file name
output_file = os.path.splitext(input_file)[0] + "_timing.txt"
# Open the input and output files
with open(input_file, 'r', encoding='utf-8') as f:
lines = f.readlines()
with open(output_file, 'w', encoding='utf-8') as f:
# Iterate through every fourth line starting from line 2
for i in range(1, len(lines), 4):
# Write the line to the output file
f.write(lines[i])
# Delete the contents of every fourth line starting from line 2
for i in range(1, len(lines), 4):
lines[i] = '\n'
# Save the modified lines back to the input file
with open(input_file, 'w', encoding='utf-8') as f:
f.writelines(lines)
Save as srt_timing_restore.py, then run python srt_timing_restore.py
import os
# Input file name
input_file = r"w:\subs\ようちえん戦隊げんきっず 13.srt"
# Timing file name
timing_file = input_file[:-4] + "_timing.txt"
# Open the input and timing files
with open(input_file, 'r', encoding='utf-8') as f:
lines = f.readlines()
with open(timing_file, 'r', encoding='utf-8') as f:
timing_lines = f.readlines()
# Insert the timing lines back into the original file at every fourth line starting from line 2
for i in range(1, len(lines), 4):
lines[i] = timing_lines.pop(0)
# Save the modified lines back to the input file
with open(input_file, 'w', encoding='utf-8') as f:
f.writelines(lines)
On a 3060 12GB with a Qwen 32B Q4_K_S translating a cleaned up script for a 5 min long anime takes about 7.5 minutes.