ThioJoe / Auto-Synced-Translated-Dubs

Automatically translates the text of a video based on a subtitle file, and also uses AI voice to dub the video, and synced using the subtitle's timings
GNU General Public License v3.0
1.55k stars 152 forks source link

Having a large subtitles file causes a crash (chunk translation) #26

Closed sofiadparamo closed 1 year ago

sofiadparamo commented 1 year ago

The usage of batch translation causes the program to crash due to an list index out of range, as seen here:

...
  File "Auto-Synced-Translated-Dubs\main.py", line 425, in translate_dictionary
    inputSubsDict[key]['translated_text'] = translatedTexts[i]
IndexError: list index out of range

This is due to the program iterating thru the chunks of translated text, and going to the range of the size of the whole list of texts to translate, causing it to crash if there are more than 100 texts in the srt file.

The list will always have 100 chunks of text, but the for loop is going beyond that.

main.py
                   Here's the problem
                           |
                           v
                   ------------------------
424| for i, key in enumerate(inputSubsDict):
425|                    inputSubsDict[key]['translated_text'] = translatedTexts[i]
426|                    # Print progress, ovwerwrite the same line
427|                    print(f' Translated: {key} of {len(inputSubsDict)}', end='\r')
Alokkumar8 commented 10 months ago

its still causing crash. is this bug fixed. it crashed on this line in translate.py inputSubsDict[key]['translated_text'] = process_response_text(translatedTexts[i], targetLanguage) image