Subtitles Class
Subtitles
¶
From a raw FFmpeg extraction, process the text and translate it using a given Translator object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raw_subtitles |
list[str]
|
Subtitles line by line |
required |
sub_format |
str
|
sub_format of the extracted subtitles. Defaults to "srt". |
'srt'
|
Source code in subtitles_translator/subtitles.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
build_aggregated_dico()
¶
After converting raw extraction to list of lines, aggregates and clean lines in order to be able to translate them. When two lines are combined, both indexes are saved in order to replace each line at the end.
Source code in subtitles_translator/subtitles.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
save_srt(path='translated.srt')
¶
Save current subtitles into an srt files. If translate_subtitles was called before, this results in a translated srt file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str | os.PathLike
|
Path to the target SRT file. Defaults to "translated.srt". It is always saved, it is used to put back subtitles with FFmpeg. |
'translated.srt'
|
Source code in subtitles_translator/subtitles.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|