├── .gitignore
├── LICENSE
├── README.md
├── requirements.txt
├── setup.cfg
├── setup.py
├── translated_example.png
├── translatesubs
├── __init__.py
├── main.py
├── managers
│ ├── __init__.py
│ ├── language_manager.py
│ └── subs_manager.py
├── translators
│ ├── __init__.py
│ ├── google_trans_new.py
│ ├── googletrans.py
│ ├── itranslator.py
│ ├── language.py
│ └── translated.py
└── utils
│ ├── __init__.py
│ ├── constants.py
│ └── tools.py
├── truncated.ass
└── version.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | *.DS_Store
2 |
3 | # Byte-compiled / optimized / DLL files
4 | __pycache__/
5 | *.py[cod]
6 | *$py.class
7 |
8 | # C extensions
9 | *.so
10 |
11 | # Distribution / packaging
12 | .Python
13 | build/
14 | develop-eggs/
15 | dist/
16 | downloads/
17 | eggs/
18 | .eggs/
19 | lib/
20 | lib64/
21 | parts/
22 | sdist/
23 | var/
24 | wheels/
25 | pip-wheel-metadata/
26 | share/python-wheels/
27 | *.egg-info/
28 | .installed.cfg
29 | *.egg
30 | MANIFEST
31 |
32 | # PyInstaller
33 | # Usually these files are written by a python script from a template
34 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
35 | *.manifest
36 | *.spec
37 |
38 | # Installer logs
39 | pip-log.txt
40 | pip-delete-this-directory.txt
41 |
42 | # Unit test / coverage reports
43 | htmlcov/
44 | .tox/
45 | .nox/
46 | .coverage
47 | .coverage.*
48 | .cache
49 | nosetests.xml
50 | coverage.xml
51 | *.cover
52 | *.py,cover
53 | .hypothesis/
54 | .pytest_cache/
55 |
56 | # Translations
57 | *.mo
58 | *.pot
59 |
60 | # Django stuff:
61 | *.log
62 | local_settings.py
63 | db.sqlite3
64 | db.sqlite3-journal
65 |
66 | # Flask stuff:
67 | instance/
68 | .webassets-cache
69 |
70 | # Scrapy stuff:
71 | .scrapy
72 |
73 | # Sphinx documentation
74 | docs/_build/
75 |
76 | # PyBuilder
77 | target/
78 |
79 | # Jupyter Notebook
80 | .ipynb_checkpoints
81 |
82 | # IPython
83 | profile_default/
84 | ipython_config.py
85 |
86 | # pyenv
87 | .python-version
88 |
89 | # pipenv
90 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
91 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
92 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
93 | # install all needed dependencies.
94 | #Pipfile.lock
95 |
96 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
97 | __pypackages__/
98 |
99 | # Celery stuff
100 | celerybeat-schedule
101 | celerybeat.pid
102 |
103 | # SageMath parsed files
104 | *.sage.py
105 |
106 | # Environments
107 | .env
108 | .venv
109 | env/
110 | venv/
111 | ENV/
112 | env.bak/
113 | venv.bak/
114 |
115 | # Spyder project settings
116 | .spyderproject
117 | .spyproject
118 |
119 | # Rope project settings
120 | .ropeproject
121 |
122 | # mkdocs documentation
123 | /site
124 |
125 | # mypy
126 | .mypy_cache/
127 | .dmypy.json
128 | dmypy.json
129 |
130 | # Pyre type checker
131 | .pyre/
132 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TranslateSubs
2 | It is a tool to translate movie subtitles from one language into another, or even show multiple language subtitles together. The tool is powered by Google Translate, thus even though the translations might not always be perfect, it supports a very wide range of languages!
3 |
4 | # About
5 |
6 | The translator can be either used to automatically extract the subtitle from the video file (e.g. .avi, .mkv) and then perform translation on that subtitle file or process a subtitle file (e.g. .srt, .ass) instead. The first required an ffpmeg installed and setup to work from terminal. If you extract subtitle yourself, note that often the file format for subtitles is SRT. This only has minimal styling thus Anime usually uses ASS format, which can even do animations. I recommend naming output file as some_name.ass if you want the styling to remain and some_name.srt if you do not want styling.
7 |
8 | Another really nice feature is being able to merge both the translation AND the original subtitles together. The original can be made smaller and slightly opaque to not distract and not take up too much space:
9 |
10 |
11 |
12 |
13 |
14 | Disclaimer: The tool relies on 3rd party tools such as `googletrans` and `google-trans-new`, thus if too many subtitles are translated at once, these tools will stop working, since Google will effectively ban the IP address and your translated subtitle will effectively show the original language instead. If this happens you have to wait a couple of days for this to start working again. IF you do not push the tool too much, say 1-2 translated movies per evening, it should be fine, it is fine for me. I am currently looking into using an alternative translation tool, where this could be fixed in some way.
15 |
16 | # Installation
17 |
18 | The package lives in PyPI, thus you can install it through pip. The tool is then accessible through terminal:
19 |
20 | pip install translatesubs
21 | translatesubs -h
22 |
23 | ## Basic Example
24 |
25 | To translate an existing subtitle file (e.g. the provided truncated.ass) and translate to Spanish (default is Spanish):
26 |
27 | translatesubs truncated.ass out.ass --to_lang es
28 |
29 | This will generate out.ass subtitle file, which can be imported in the VLC player via `Subtitles -> Add Subtitle File...` or simply dragged and dropped onto the VLC player.
30 |
31 | ## Use video file
32 |
33 | If a video file is being used instead e.g. video.mkv, subs will be extracted automatically using ffmpeg library before processing them:
34 |
35 | translatesubs video.mkv english_translated.ass --to_lang en
36 |
37 | Some video files might have multiple subtitle tracks. You can select the track you want to use (starting from 0) using argument `--subs_track`:
38 |
39 | translatesubs video.mkv english_translated.ass --to_lang en --subs_track 1
40 |
41 | ## Display two languages at once
42 |
43 | If you would like to learn a new language, you might as well show both, the language you would like to learn (Main) AND the one you speak very well (Secondary) (slightly smaller font and slightly opaque to not disturb, as shown in the example picture).
44 |
45 | E.g. If the language you speak is English and you would like to learn Spanish for some series, that does NOT provide Spanish subtitles, simply use flag `--merge` and English subs will be translated into `Spanish(translated) + English`:
46 |
47 | translatesubs english.ass spanish_translated+english_original.ass --to_lang es --merge
48 |
49 | If, however, the series DOES have spanish subtitles, I would instead recommend translating the Spanish into English, since Google translate does not give 100% accurate text, thus by translating FROM Spanish you will get better Spanish subs quality, while English will not matter that much, since it is there just for clarification. To make sure that you still see the Spanish on top and English at the bottom use flag `--reverse`, which will then generate `Spanish + English(translated)` subs:
50 |
51 | translatesubs spanish.ass spanish_original+english_translated.ass --to_lang en --merge --reverse
52 |
53 | Another flag, which is useful when merging two languages together is `--line_char_limit`. Often instead of showing one long line, two or even three lines are displayed in subs. While they all would still fit within a single line after being translated, when `--merge` is used, that would double the line count and would block a large portion of the video. To solve this add `--line_char_limit` with a number of around 70. This basically means that if there are less than 70 characters within a sub, remove all new lines (aka do not split the line in multiples). Of course, for some subs this number could be higher, or lower, depending on the font size. Thus you might have to test a little bit, but sticking to the default 70-80 is a good starting point:
54 |
55 | translatesubs spanish.ass spanish+english_translated.ass --to_lang en --merge --reverse --line_char_limit 80
56 |
57 | You can also change the secondary subtitle (on the bottom) font size and opacity using `--secondary_scale` and `--secondary_alpha` respectively. 100 scale will represent font size equal to the main subs at the top (default is 80%), while 100 alpha will be completely transparent, thus you would want alpha value that is below 100 (default is 55%). For example:
58 |
59 | translatesubs spanish.ass english_translated+spanish.ass --to_lang en --merge --secondary_scale 50 --secondary_alpha 60
60 |
61 | ## Display pronunciation
62 |
63 | Languages like Japanese, Chinese and many others use a non-latin characters. If you are learning a new language, it is likely you can't read the new alphabet as quickly as it is required to follow the subs. For that purpose `--pronounce_translated` to show pronunciation of the translation and `--pronounce_original` to show pronunciation of the original subs.
64 |
65 |
66 | E.g. you might be learning Japanese and can't be bothered learning all the Hiragana, Katakana and Kanji, but you want to start understanding better Anime as you watch it. In that case it is best to find Japanese subs on `kitsunekko.net` and use `--pronounce_original` flag (also note `--merge` and `--reverse`):
67 |
68 | translatesubs japanese.ass japanese_pronounced+english_translated.ass --to_lang en --merge --reverse --pronounce_original
69 |
70 | If you have more advanced Japanese understanding (yet cannot read the characters), you can remove English subs altogether by performing Japanese to Japanese translation, but adding `--pronounce_translated` flag:
71 |
72 | translatesubs japanese.ass japanese_pronounced.ass --to_lang ja --pronounce_translated
73 |
74 | Alternatively, if you cannot find the japanese subs you can translate the english ones straight to Japanese, however can't guarantee that what is being spoken is exactly what you will be reading since Japanese language is more difficult to translate...
75 |
76 | translatesubs english.ass japanese_pronounce+english.ass --to_lang en --pronounce_translated
77 |
78 | ## Select the translator provider
79 |
80 | The tool supports a couple of translation libraries: `googletrans` and `google_trans_new`. In rare cases the translation might fail using one of the libraries. When that happens simply try another one :) You can choose which one to use with flag `--translator`:
81 |
82 | translatesubs truncated.ass out.ass --to_lang es --translator google_trans_new
83 |
84 | In the future I would like to add official google translate API support, but that would require acquiring Google Translation API Key and passing it into the tool. If, however, you're translating 1-5 episodes per day, then using one of the two supported APIs is OK, however for very large amounts official API would be best, since then you could extend quota limits.
85 |
86 | Note: `google_trans_new` ignores ALL new lines, meaning if there was some new lines `\n` within original subs, they will ALL get removed in both translations AND pronunciations. `googletrans` on the other hand keeps the new lines within translations, however removes them for pronunciations. Also note that the behavior might change in the future, since I am not responsible for maintaining these libraries.
87 |
88 | ## Advanced Stuff
89 |
90 | Instead of sending subs one by one to be translated the tool combines as many subs as possible into large chunks and sends those chunks instead. Otherwise 1) you would get blocked by Google after translating 1-2 series and 2) Since some subs do not contain a full sentence, the translation will be more accurate when sending full sentences. To achieve this, however, one needs some special character (or character set), that Google Translate would treat as something non-translatable, however would still keep it e.g. separate each sub with ` ∞ `, `@@`, ` ### `, ` $$$ `. This separator needs to be different depending on the subtitle stream and the tool tries one separator after another until translation succeeds. Separator is created by using a single special character in combinations like "X", " X ", "XX", " XX ", "XXX", " XXX ", where X is that special character. I found that different languages work best with certain separators best:
91 | - Japanese - " ∞ ", " ™ ", "$$$"
92 | - Simplified Chinese - "@@", "@@@"
93 | - Albanian - "@@", "@@@"
94 | - Polish - "@@@", "$$$", "€€€"
95 | - Greek - "$$", " $$ ", "$$$", " $$$ "
96 |
97 | You can overwrite the default behavior of trying separator one by one by passing one yourself e.g. `--separator " ### "`
98 |
99 | # Note
100 |
101 | The tool uses a free googletrans API, which uses one of the google domains e.g. translate.google.com or translate.google.co.uk to perform translation. After a couple of calls that domain gets blocked and thus another one is selected instead. I added 17 domains, which should ensure that you will always have a domain that still works, because after about 1h that domain gets unblocked. Don't worry, you can still go to chrome and use the google translate :)
102 |
103 | The tool works best with English language, since some others might have strange characters that might make things funny... However the use of different separators selected automatically should ensure that things work (I did see Portugese fail for some reason, might have to investigate later). Although even in case of failure I made sure that even if it fails, it continues and produces the subs, just they might be misaligned with the main subs text...
104 |
105 | # Development
106 |
107 | During the development process, it is worth loading the whole project folder (aka watch lib updates) rather than rebuilding and performing installation after every code change. This is done using `pip install -e .`. To generate installable wheel, do `python setup.py sdist bdist_wheel`, which will output build files within `dist/` folder.
108 |
109 | # Automatic subs extraction from a video
110 |
111 | If you cannot get the subtitles for some video, there is a way to get "unpredictable" quality subs by extracting the audio from a video file and then using Google Web Speech API to create subs. Two projects that worked pretty smoothly were [autosub](https://github.com/agermanidis/autosub) and [pyTranscriber](https://github.com/raryelcostasouza/pyTranscriber). The first is only supported on python2 and the second is a GUI application, which is based on the first utility, with the code updated to work with python3. One problem with that one is not being able to select all kinds of file formats, only some specific ones. A way around this is to download the source code and modifying file `pytranscriber/control/ctr_main.py` line that contains `"All Media Files (*.mp3 *.mp4 *.wav *.m4a *.wma)"`. You need to add some file e.g. if .mkv is required, then add *.mkv. I personally would just download both projects source code and replace the `__init__.py` file within autosub project with `autosub/__init__.py` from pyTranscriber. Then just use autosub as per documentation with python3. Of course you can build wheel and install it or just do `pip install -e .` to install without building the wheel. This way is still far from perfect, however one day the transcription will get a lot better results, hopefully that day is on the corner!
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | pysubs2==1.6.0
2 | googletrans==3.1.0a0
3 | google-trans-new==1.1.9
4 | chardet==3.0.4
5 | requests==2.28.2
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [metadata]
2 | description-file = README.md
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import find_packages, setup
2 |
3 | with open('README.md', 'r') as fh:
4 | long_description = fh.read().strip()
5 |
6 | with open('version.txt', 'r') as fh:
7 | version = fh.read().strip()
8 |
9 | SETUP_ARGS = dict(
10 | name='translatesubs',
11 | version=version,
12 | license='Apache-2.0',
13 | author='Montvydas Klumbys',
14 | author_email='montvydas.klumbys@gmail.com',
15 | description='It is a tool to translate subtitles into any language, that is supported by google translator',
16 | long_description=long_description,
17 | long_description_content_type='text/markdown',
18 | url='https://github.com/Montvydas/translatesubs',
19 | download_url=f'https://github.com/Montvydas/translatesubs/archive/v_{version}.tar.gz',
20 | keywords=['SUBTITLES', 'TRANSLATE'],
21 | packages=find_packages(),
22 | install_requires=[
23 | 'pysubs2==1.6.0',
24 | 'googletrans==3.1.0a0',
25 | 'google-trans-new==1.1.9',
26 | 'chardet==3.0.4',
27 | 'requests==2.28.2',
28 | ],
29 | classifiers=[
30 | 'Development Status :: 4 - Beta',
31 | 'Programming Language :: Python :: 3',
32 | 'License :: OSI Approved :: Apache Software License ',
33 | 'Operating System :: OS Independent',
34 | 'Topic :: Multimedia :: Video',
35 | ],
36 | python_requires='>=3.6',
37 | entry_points={
38 | 'console_scripts': [
39 | 'translatesubs=translatesubs.main:main'
40 | ]
41 | },
42 | )
43 |
44 |
45 | if __name__ == "__main__":
46 | setup(**SETUP_ARGS)
47 |
--------------------------------------------------------------------------------
/translated_example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Montvydas/translatesubs/955cf46ead2657e6e4218de23efaa5a33e83f40a/translated_example.png
--------------------------------------------------------------------------------
/translatesubs/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Montvydas/translatesubs/955cf46ead2657e6e4218de23efaa5a33e83f40a/translatesubs/__init__.py
--------------------------------------------------------------------------------
/translatesubs/main.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | from translatesubs.managers.language_manager import LanguageManager
4 | from translatesubs.managers.subs_manager import SubsManager
5 | from translatesubs.utils.constants import AVAILABLE_TRANSLATORS, TRANSLATORS_PRINT, DEFAULT_SEPS_PRINT, USE_DEFAULT_SEPS, \
6 | DEFAULT_SEPS, SEP_MAX_LENGTH, SUB_FORMATS
7 |
8 | import argparse
9 | import logging
10 | import sys
11 | from typing import List
12 | import os
13 |
14 | """
15 | Future Development:
16 | 1) Automatically detect the subs language using "from_lang" argument, which would be more automatic than subs_track.
17 | 2) Add official google translate api and ability to setup your google api key.
18 | """
19 |
20 |
21 | def main():
22 | parser = argparse.ArgumentParser(
23 | description='It is a tool to translate movie subtitles from one language into another, or even show multiple '
24 | 'language subtitles together.',
25 | usage='python translatesubs.py video.mkv output.ass --merge --to_lang fr')
26 | parser.add_argument('input', type=str,
27 | help='Input file to translate; By default it is a subtitle file but if flag --video_file is'
28 | ' set, then this is video file name.')
29 | parser.add_argument('output', type=str, help='Generated translated subtitle file.')
30 | parser.add_argument('--encoding', default='utf-8', type=str,
31 | help='Input file encoding, which defaults to "utf-8". To determine it automatically use "auto"')
32 | parser.add_argument('--to_lang', default='es', type=str, help='Language to which translate to.')
33 | parser.add_argument('--pronounce_original', action='store_true',
34 | help='Use pronunciation rather than writing form for origin subs e.g. useful for Japanese')
35 | parser.add_argument('--pronounce_translated', action='store_true',
36 | help='Use pronunciation rather than writing form for translated subs e.g. useful for Japanese')
37 | parser.add_argument('--merge', action='store_true',
38 | help='Set to see both, the original (at bottom) and the translated (on top), subtitles.')
39 | parser.add_argument('--reverse', action='store_true',
40 | help='Display original subs on top and translated at the bottom instead, when --merge is set.')
41 | parser.add_argument('--secondary_scale', default=80, type=int,
42 | help='Specify the secondary subs scale factor where 100 is its original size.')
43 | parser.add_argument('--secondary_alpha', default=50, type=int,
44 | help='Specify the secondary subs opacity in percent, where 100 is completely transparent.')
45 | parser.add_argument('--line_char_limit', default=30, type=int,
46 | help='Decide if keep multiple, often short, lines or merge them into one instead. Best '
47 | 'used with --merge flag since then extra lines are added. Recommended value 30 or 70.')
48 | parser.add_argument('--input_type', default='auto', choices=['auto', 'video', 'subs'],
49 | help='Specify input file type. By default it tries to automatically deduce the type.')
50 | parser.add_argument('--subs_track', default=0, type=int,
51 | help='Select subtitle track (starting from 0), used when video has multiple subtitles attached to it.')
52 | parser.add_argument('--translator', default='googletrans', type=str,
53 | help=f'One of the Translate services to use: {TRANSLATORS_PRINT}. googletrans does a better '
54 | 'job when pronunciation is needed, since it preserves new lines, however it very easily '
55 | 'gets corrupted, thus often many different separators have to be tried. On the other hand '
56 | 'google_trans_new seems to work very well, but removes new line chars in pronunciation...')
57 |
58 | parser.add_argument('--logging', default=40, type=int,
59 | help='NOTSET - 0, DEBUG - 10, INFO - 20, WARNING - 30, ERROR - 40, CRITICAL - 50')
60 | parser.add_argument('--ignore_line_ends', action='store_true',
61 | help='Set this when you are sure that subs do not have line end characters such as ?!. or'
62 | 'others, since we rely on them to split the text correctly! e.g. machine generated subs'
63 | 'will not include line end characters.')
64 | parser.add_argument('--separator', default=USE_DEFAULT_SEPS, type=str,
65 | help='Special subtitle separator when sending it to be translated. Sometimes will just have to '
66 | 'experiment, since different language combinations require different one. I found " $$$ " '
67 | 'to work with majority of languages, however not all of them. The separators are created '
68 | 'using some weird character in various combinations like "X", " X ", "XX", " XX ", '
69 | f'"XXX", " XXX ", where X is that weird character. Do not use more than {SEP_MAX_LENGTH} '
70 | 'chars as a separator. Separators for these languages work best:\n'
71 | 'Japanese - " ∞ ", " ™ ", "$$$"\n'
72 | 'Simplified Chinese - "@@", "@@@"\n'
73 | 'Albanian - "@@", "@@@"\n'
74 | 'Polish - "@@@", "$$$", "€€€"\n'
75 | 'Greek - "$$", " $$ ", "$$$", " $$$ "\n'
76 | '...\n'
77 | 'Be careful when using $ sign, since terminal treats it as argument input, thus need a '
78 | 'backslash for it.\n'
79 | f'Default behavior tries separators one by one from the list: {DEFAULT_SEPS_PRINT}. '
80 | 'If these do not work, then only some good hack can help u :)')
81 | args = parser.parse_args()
82 |
83 | logging.basicConfig(stream=sys.stderr, level=args.logging)
84 | logging.info(f'Using logging level {logging.getLogger()} - lvl {logging.getLogger().level}.')
85 |
86 | # Prepare original subs: extract text and styling
87 | filename = get_subs_file(args)
88 | subs_manager = SubsManager(filename=filename, encoding=get_encoding(args.encoding, filename))
89 | subs_manager.extract_line_styling()
90 |
91 | # Perform translation: prepare extracted subs for translating and try different separators to see which will work
92 | translator = get_translator(args.translator)
93 | language_manager = get_language_manager(args.to_lang, args.ignore_line_ends, translator)
94 | language_manager.prep_for_trans(subs_manager.just_text())
95 | original, translated = translate(language_manager, separators_to_try(args.separator),
96 | args.pronounce_original, args.pronounce_translated)
97 |
98 | # To display firstly original and translated below instead
99 | if args.reverse:
100 | original, translated = translated, original
101 |
102 | subs_manager.update_subs(main_subs=translated, secondary_subs=original,
103 | merge=args.merge, secondary_scale=args.secondary_scale,
104 | secondary_alpha=args.secondary_alpha, char_limit=args.line_char_limit)
105 | subs_manager.save_subs(args.output)
106 | print('Finished!')
107 |
108 |
109 | def get_encoding(encoding, filename):
110 | if encoding == 'auto':
111 | import chardet
112 | with open(filename, "rb") as f:
113 | res = chardet.detect(f.read())
114 | return res['encoding']
115 | return encoding
116 |
117 | def get_subs_file(args):
118 | extension = os.path.splitext(args.input)[1].strip('.')
119 | if args.input_type == 'subs' or (args.input_type == 'auto' and extension in SUB_FORMATS):
120 | return args.input
121 |
122 | # must have selected video, simply extract the subtitle and return it's path
123 | if not SubsManager.extract_from_video(video_in=args.input, subs_track=args.subs_track, subs_out=args.output):
124 | exit('Could not extract the subtitles!')
125 |
126 | print(f'Extracted subtitles from "{args.input}" into "{args.output}".')
127 | return args.output
128 |
129 |
130 | def get_language_manager(to_lang, ignore_line_ends, translator):
131 | # Ensure that the language is valid and is supported
132 | language_manager = LanguageManager.create_instance(to_lang=to_lang,
133 | ignore_line_ends=ignore_line_ends,
134 | translator=translator)
135 | if not language_manager:
136 | exit(f'Cannot detect language "{to_lang}". Supported either abbreviation or full language name:\n'
137 | f'{translator.get_supported()}.')
138 |
139 | print(f'Translating to "{language_manager.to_lang.full_name}".')
140 | return language_manager
141 |
142 |
143 | def get_translator(translator_name):
144 | # Instantiate one of the translators
145 | translator = AVAILABLE_TRANSLATORS.get(translator_name, None)
146 | if not translator:
147 | exit(f'Translator "{translator_name}" is not supported. '
148 | f'Try one of the supported ones: {TRANSLATORS_PRINT}.')
149 |
150 | return translator()
151 |
152 |
153 | def translate(language_manager, separators, pronounce_origin, pronounce_trans):
154 | for sep in separators:
155 | print(f'Trying separator "{sep}"...')
156 | language_manager.set_separator(sep)
157 | original, translated = language_manager.translate_text(pronounce_origin=pronounce_origin,
158 | pronounce_trans=pronounce_trans)
159 | if LanguageManager.valid_translation(original, translated):
160 | return original, translated
161 |
162 | # This we do not want to reach!
163 | exit('It seems like all tries to translate got corrupted. Try to manually set the separator using '
164 | f'--separator argument to be DIFFERENT from: {DEFAULT_SEPS_PRINT}. Check --help menu for more information.')
165 |
166 |
167 | def separators_to_try(separator_input) -> List[str]:
168 | if separator_input != USE_DEFAULT_SEPS:
169 | return [separator_input]
170 |
171 | return DEFAULT_SEPS
172 |
173 |
174 | if __name__ == "__main__":
175 | main()
176 |
--------------------------------------------------------------------------------
/translatesubs/managers/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Montvydas/translatesubs/955cf46ead2657e6e4218de23efaa5a33e83f40a/translatesubs/managers/__init__.py
--------------------------------------------------------------------------------
/translatesubs/managers/language_manager.py:
--------------------------------------------------------------------------------
1 | from __future__ import annotations
2 |
3 | import re
4 | import logging
5 | from typing import List, Tuple, Iterator
6 | from translatesubs.translators.itranslator import ITranslator
7 | from translatesubs.translators.language import Language
8 | from translatesubs.utils.constants import ENDS_OF_SENTENCES, DEFAULT_SEPS, SEP_MAX_LENGTH
9 |
10 |
11 | class LanguageManager:
12 |
13 | def __init__(self, to_lang: Language, ignore_line_ends: bool, translator: ITranslator):
14 | self.to_lang = to_lang
15 | # Separator was chosen after noting that not all will be treated as non-text object and others
16 | # such as @@ will not translate all words e.g. "Connect @@ Something else..." Will not translate correctly :/
17 | # While Connect ## Something else... will do.
18 | self.separator = DEFAULT_SEPS[0]
19 | self.ignore_line_ends = ignore_line_ends
20 | self.translator = translator
21 | self.prepared = None
22 |
23 | @classmethod
24 | def create_instance(cls, to_lang: str, ignore_line_ends: bool, translator: ITranslator) -> LanguageManager:
25 | language = translator.detect_language(to_lang)
26 | return cls(language, ignore_line_ends, translator) if language else None
27 |
28 | def set_separator(self, new_separator: str):
29 | self.separator = new_separator
30 |
31 | def prep_for_trans(self, text: Iterator[str]):
32 | self.prepared = self._prepare_for_translation(text)
33 |
34 | def translate_text(self, pronounce_origin: bool, pronounce_trans: bool) -> Tuple[List[str], List[str]]:
35 | if not self.prepared:
36 | raise Exception('Text needs to be prepared for translation first.')
37 |
38 | properly_separated_chunks = self.combine_with_separator()
39 | translated = self.translator.translate(properly_separated_chunks, self.to_lang.abbreviation)
40 |
41 | # Noticed that when separator contains spaces e.g. ' ∞ ', translated to certain languages separator gets
42 | # modified e.g. English to Japanese "Hello ∞ everyone" -> "みなさん、こんにちは∞" OR "Minasan, kon'nichiwa ∞"
43 | sep = self.separator.strip()
44 |
45 | extracted_original = []
46 | extracted_translated = []
47 |
48 | for trans in translated:
49 | extracted_original.extend(LanguageManager._extract_translation(
50 | trans.pronounce_original if pronounce_origin else trans.original, sep))
51 |
52 | extracted_translated.extend(LanguageManager._extract_translation(
53 | trans.pronounce_translated if pronounce_trans else trans.translated, sep))
54 |
55 | return extracted_original, extracted_translated
56 |
57 | @staticmethod
58 | def valid_translation(original, translated):
59 | valid = original and translated and len(original) == len(translated)
60 | if not valid:
61 | print(f'original length={len(original)}, translated length={len(translated)}')
62 | return valid
63 |
64 | @staticmethod
65 | def _extract_translation(chunk, separator):
66 | return [sub.strip() for sub in chunk.split(separator)]
67 |
68 | def _prepare_for_translation(self, text_lst: Iterator[str]) -> List[List[str]]:
69 | """Prepares list of text to be translated by going through every text element in the list and
70 | grouping them into allowed char 5000 limits, which is placed by google translate service.
71 | _next_available_sentence function generates a list of text, that comprise a full sentence. Then
72 | sentences are grouped into larger list, which ensures that if SEP_MAX_LENGTH line separator is added, the total
73 | character count doesn't take up more than the allowed 5000 limit.
74 |
75 | If this is not done, too many requests will be generated and Google will block the translate service. It should
76 | also improve the accuracy, since Translator has the access to the whole sentence rather than just a part of it.
77 |
78 | Example:
79 | The bottom list of text using char limit of 40 will be require going sentence by sentence
80 | (using _next_available_sentence) and checking if new sentence fits within char limits:
81 | ["This is an,", "example text!", "I am writing this now..."] ->
82 | new_sentence = ["This is an,", "example text!"] ->
83 | 24 chars in new_sentence, 0 + 24 = 24 chars in total inside this part, thus save it in:
84 | single_chunk.extend(new_sentence)
85 |
86 | Get a new sentence and check if that still fits:
87 | new_sentence = ["I am writing this now..."] ->
88 | 24 chars in new_sentence, 24 + 24 = 48 chars in total - TOO MUCH! Save previous part and store this in new:
89 | chunks.append(new_sentence)
90 | single_chunk = []
91 | single_chunk.extend(new_sentence)
92 |
93 | This will finally generate such a nested list:
94 | [["This is an,", "example text!"], ["I am writing this now..."]]
95 |
96 | This is overall slower than the regex solution for large chunk size"""
97 | grouped_chunks = []
98 | single_chunk = []
99 | char_count = 0
100 | separator_length = SEP_MAX_LENGTH
101 | for sentence in self._next_available_sentence(text_lst):
102 | sentence_length = sum([len(part) for part in sentence]) + len(sentence) * separator_length
103 | logging.debug(f'sentence: {sentence[0][:10]}...{sentence[-1][-10:]} with {len(sentence)} texts, '
104 | f'{char_count} (char count) + {sentence_length} (sentence length) '
105 | f'= {char_count + sentence_length} (total)')
106 | if char_count + sentence_length > self.translator.get_char_limit():
107 | logging.debug(f'Reached the {self.translator.get_char_limit} char limit!')
108 | grouped_chunks.append(single_chunk)
109 | char_count = 0
110 | single_chunk = []
111 |
112 | char_count += sentence_length
113 | single_chunk.extend(sentence)
114 |
115 | if single_chunk:
116 | grouped_chunks.append(single_chunk)
117 |
118 | return grouped_chunks
119 |
120 | def combine_with_separator(self):
121 | # Combine text chunks by some GOOD separator, such as ' ## ' that google translate would keep in place instead
122 | # of removing after translation. This will allow us to send all of the text to be sent for translation,
123 | # yet still track of the what lines belong to which timestamp
124 | chunks_to_translate = [self.separator.join(partial) for partial in self.prepared]
125 | logging.debug(f'Prepared {len(chunks_to_translate)} chunks to be translated.')
126 | return chunks_to_translate
127 |
128 | @staticmethod
129 | def _next_available_sentence(text_lst: Iterator[str]) -> Iterator[str]:
130 | """Generates a list of text, that comprise a full sentence."""
131 | all_possible_endings = ''.join(ENDS_OF_SENTENCES.values())
132 | sentence_endings = re.compile(f'[{all_possible_endings}]$', flags=re.DOTALL)
133 | collected = []
134 |
135 | for sentence in text_lst:
136 | collected.append(sentence)
137 | if sentence_endings.search(sentence):
138 | yield collected
139 | collected = []
140 |
141 | if collected:
142 | yield collected
143 | return
144 |
145 | def _prepare_for_translation_using_regex(self, text_lst: Iterator[str]) -> List[str]:
146 | """Prepares list of text to be translated by firstly joining the lines using a special separator
147 | and then taking a chunk of max allowed char and looking back for matching sentence end.
148 |
149 | E.g. the bottom list of text using char limit of 40 will be firstly joined into one string:
150 | ["This is an,", "example text!", "I am writing this now..."] ->
151 | "This is an, ## example text! ## I am writing this now..."
152 |
153 | Then it will be separated into parts:
154 | "This is an, ## example text! ## I am wri" AND "ting this now..." -> (take first 40 chars)
155 | "This is an, ## example text!" AND " ## I am writing this now..." -> (use regex to find last full sentence)
156 | ["This is an, ## example text!", "I am writing this now..."] -> (repeat for the second part until done)
157 | """
158 | # Slower method
159 | # .+[.!?"\')]( ## ).+$
160 | # Quicker method
161 | # TODO check if need to use * or + at the end: *$ vs +$, original was +$
162 | # [.!?"\')]( ## )(?:.(?![.!?"\')] ## ))*$
163 | # OR when no valid endings found e.g. some strange language or subs don't have sentence endings incorporated..
164 | # ( ## )(?:.(?! ## ))*$
165 | full_text = self.separator.join(text_lst)
166 | valid_endings = self._determine_valid_endings(full_text)
167 |
168 | # special regex characters need to be escaped. For now $ works very well but in regex it also matches the end
169 | # of sentence, thus escape it :)
170 | processed_separator = self.separator.replace('$', '\\$')
171 | # Note that when no valid endings found, simply separate by the closest subtitle instead
172 | splitter = re.compile(f'{valid_endings}({processed_separator})'
173 | f'(?:.(?!{valid_endings}{processed_separator}))*$', flags=re.DOTALL)
174 |
175 | curr_index = 0
176 | chunks_to_translate = []
177 | total_length = len(full_text)
178 |
179 | while curr_index + self.translator.get_char_limit() < total_length:
180 | curr_split = full_text[curr_index:curr_index + self.translator.get_char_limit()]
181 | split_place = splitter.search(curr_split)
182 | if not split_place:
183 | exit('It seems like some translations got corrupted. Try a different separator using --separator '
184 | 'argument. Check --help menu for more information.')
185 | chunks_to_translate.append(curr_split[:split_place.start(1)])
186 | curr_index += split_place.end(1)
187 | chunks_to_translate.append(full_text[curr_index:curr_index + self.translator.get_char_limit()])
188 | logging.debug(f'Prepared {len(chunks_to_translate)} chunks to be translated.')
189 |
190 | return chunks_to_translate
191 |
192 | def _determine_valid_endings(self, full_text):
193 | if self.ignore_line_ends:
194 | return ''
195 | for name, endings in ENDS_OF_SENTENCES.items():
196 | re_endings = f'[{endings}]'
197 | if re.search(re_endings, full_text, flags=re.DOTALL):
198 | logging.info(f'Using "{name}" endings "{endings}"')
199 | return re_endings
200 | logging.info(f'No valid line ends found, thus ignoring them.')
201 | return ''
202 |
--------------------------------------------------------------------------------
/translatesubs/managers/subs_manager.py:
--------------------------------------------------------------------------------
1 | import pysubs2
2 | import subprocess
3 | import logging
4 | from typing import List, Iterator
5 | import re
6 |
7 |
8 | class Sub:
9 | def __init__(self, text: str, plaintext: str):
10 | self.origin_text = text
11 | self.plaintext = plaintext
12 | self.open_style = ''
13 | self.close_style = ''
14 |
15 | @staticmethod
16 | def to_plaintext(sub: pysubs2.SSAEvent):
17 | return sub.plaintext if sub.plaintext else sub.text
18 |
19 | @staticmethod
20 | def merge_multiline(multiline: str, char_limit: int):
21 | lines_length = len(multiline.replace('\n', ''))
22 | return multiline.replace('\n', ' ').replace(' ,', ',') if lines_length < char_limit else multiline
23 |
24 | def extract_line_styling(self):
25 | match = re.search(r'^{.+?}', self.origin_text, flags=re.DOTALL)
26 | if match:
27 | # logging.info(f'Opening: {match.group()}')
28 | self.open_style = match.group()
29 |
30 | match = re.search(r'.+({.+?})$', self.origin_text, flags=re.DOTALL)
31 | if match:
32 | # logging.info(f'Closing: {match.group(1)}')
33 | self.close_style = match.group(1)
34 |
35 |
36 | class SubsManager:
37 | def __init__(self, filename: str, encoding: str='utf-8'):
38 | try:
39 | self.origin_subs = pysubs2.load(filename, encoding)
40 | except UnicodeDecodeError as e:
41 | exit(f'{e}\nTry changing encoding manually or allow "chardet" lib to determine it with: --encoding auto')
42 | self.subs = [Sub(sub.text, Sub.to_plaintext(sub)) for sub in self.origin_subs]
43 |
44 | def extract_line_styling(self):
45 | logging.info('Extracting individual line styling..')
46 | [sub.extract_line_styling() for sub in self.subs]
47 |
48 | def just_text(self) -> Iterator[str]:
49 | return (sub.plaintext for sub in self.subs)
50 |
51 | def update_subs(self, main_subs: List[str], secondary_subs: List[str], merge: bool, secondary_scale: int, secondary_alpha: int, char_limit: int):
52 | # original --> secondary
53 | # translated --> main
54 | for main, secondary, sub, origin_sub in zip(main_subs, secondary_subs, self.subs, self.origin_subs):
55 | # 1. For now ignore the in-line based styling e.g. bold single word.
56 | # 2. Replace \n with \N as otherwise the same sub will be treated as separate event aka next sub.
57 | # NOTE: When writing into plaintext, \n is replaced with \N. But we also want to add custom styling..
58 | main = Sub.merge_multiline(main, int(char_limit))
59 | main = SubsManager._replace_with_capital_newline(main)
60 |
61 | if merge:
62 | secondary = Sub.merge_multiline(secondary, int(char_limit * 100 / secondary_scale))
63 | secondary = SubsManager._replace_with_capital_newline(secondary)
64 | secondary = SubsManager._afterstyle(secondary, secondary_scale, secondary_alpha)
65 | else:
66 | secondary = ""
67 |
68 | origin_sub.text = f'{sub.open_style}{main}{secondary}{sub.close_style}'
69 |
70 | def save_subs(self, subs_out: str):
71 | self.origin_subs.save(subs_out)
72 |
73 | @staticmethod
74 | def extract_from_video(video_in: str, subs_track: int, subs_out: str) -> bool:
75 | operation = ['ffmpeg', '-i', video_in, '-map', f'0:s:{subs_track}', subs_out]
76 | logging.debug(f'Extracting subs using {" ".join(operation)}')
77 | status = subprocess.run(operation)
78 | return status.returncode == 0
79 |
80 | @staticmethod
81 | def _afterstyle(text: str, scale: int, alpha: int) -> str:
82 | alpha_scale = round(alpha * 2.55)
83 | alpha_hex = f'{alpha_scale:x}'
84 | open_style = f'\\N{{\\fscx{scale}\\fscy{scale}\\alpha&H{alpha_hex}&}}'
85 | close_style = '\\N{\\fscx100\\fscy100\\alpha&H00&}'
86 | return f'{open_style}{text}{close_style}'
87 |
88 | @staticmethod
89 | def _replace_with_capital_newline(multiline):
90 | return multiline.replace('\n', '\\N')
91 |
--------------------------------------------------------------------------------
/translatesubs/translators/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Montvydas/translatesubs/955cf46ead2657e6e4218de23efaa5a33e83f40a/translatesubs/translators/__init__.py
--------------------------------------------------------------------------------
/translatesubs/translators/google_trans_new.py:
--------------------------------------------------------------------------------
1 | import google_trans_new
2 | from typing import List, Iterator
3 | import logging
4 | import re
5 |
6 | from translatesubs.translators.itranslator import ITranslator
7 | from translatesubs.translators.language import Language
8 | from translatesubs.translators.translated import Translated
9 |
10 |
11 | class GoogleTransNew(ITranslator):
12 | """
13 | Google_trans_new suffers from a bug in the API: within the pronunciation, new line characters are removed and
14 | thus if it is important to preserve perfect styling, you are better off using another translation service.
15 | """
16 |
17 | def get_char_limit(self) -> int:
18 | return 5000
19 |
20 | def translate(self, text: List[str], to_lang: str) -> Iterator[Translated]:
21 | for original in text:
22 | pronounced = self._do_translate(original, to_lang, pronounce=True)
23 | translated = self._do_translate(original, to_lang).strip()
24 | yield Translated(original=original,
25 | translated=translated,
26 | pronounce_original=GoogleTransNew._pronounce_origin(pronounced, original),
27 | pronounce_translated=GoogleTransNew._pronounce_translated(pronounced, translated))
28 |
29 | def detect_language(self, to_lang: str) -> Language:
30 | return next((Language(full, abb) for abb, full in google_trans_new.LANGUAGES.items()
31 | if to_lang == abb or to_lang == full), None)
32 |
33 | def get_supported(self) -> str:
34 | return ', '.join([f'{abb} - {full}' for abb, full in google_trans_new.LANGUAGES.items()])
35 |
36 | @staticmethod
37 | def _do_translate(text: str, to_lang: str, pronounce=False):
38 | """
39 | Call google translate API to translate given text
40 |
41 | :param **kwargs:
42 | :param text: The source text(s) to be translated. Batch translation is supported via sequence input.
43 | :type text: UTF-8 :class:`str`; :class:`unicode`; string sequence (list, tuple, iterator, generator)
44 |
45 | :return: translated text in the same form it was provided
46 | """
47 | # Google API provider should allow new access every 1h, but if more translations need to be done,
48 | # a number of different country providers are given
49 | # E.g. from here https://sites.google.com/site/tech4teachlearn/googleapps/google-country-codes
50 | # But have to make sure the site actually loads first :)
51 | ending_formula = re.compile(r'translate\..*?\.(.+)$') # for for com, co.uk, lt or others
52 | provider_endings = (ending_formula.search(url).group(1) for url in google_trans_new.DEFAULT_SERVICE_URLS)
53 |
54 | for ending in provider_endings:
55 | translator = google_trans_new.google_translator(url_suffix=ending)
56 | try:
57 | return translator.translate(text, lang_tgt=to_lang, pronounce=pronounce)
58 | except AttributeError:
59 | logging.info(f'Provider "translate.google.{ending}" got blocked, trying another one...')
60 | exit('No more providers left to try, try updating the provider list or wait 1h until you get unblocked.')
61 |
62 | @staticmethod
63 | def _pronounce_origin(translated: List[str], default: str) -> str:
64 | return translated[1] if translated[1] else default
65 |
66 | @staticmethod
67 | def _pronounce_translated(translated: List[str], default: str) -> str:
68 | return translated[2] if translated[2] else default
69 |
--------------------------------------------------------------------------------
/translatesubs/translators/googletrans.py:
--------------------------------------------------------------------------------
1 | import googletrans
2 | from typing import List, Iterator
3 | import logging
4 | import re
5 | from translatesubs.translators.itranslator import ITranslator
6 | from translatesubs.translators.language import Language
7 | from translatesubs.translators.translated import Translated
8 | from translatesubs.utils.tools import nth
9 |
10 | """
11 | The API has problems with pronunciations:
12 | 1. cannot pronounce the original text and
13 | 2. cannot pronounce multiple sentences (pronunciation becomes None).
14 |
15 | To extract correct pronunciation data, we can look at examples:
16 |
17 | 1) how are you? -> spanish (origin: cannot pronounce, translation: cannot pronounce)
18 | [['¿cómo estás?', 'how are you?', None, None, 1]]
19 | - if the last element is a number or is not a str, then there are NO translations
20 |
21 | 2) how are you? -> japanese (origin: cannot pronounce, translation: can pronounce)
22 | [['お元気ですか?', 'how are you?', None, None, 1], [None, None, 'Ogenkidesuka?']]
23 | original pronounced does not exist, translation pronounced [-1]
24 | - if 1) is correct AND length of elements is <4, that means still cannot pronounce original
25 |
26 | 3) お元気ですか? -> english (origin: can pronounce, translation: cannot pronounce)
27 | [['How are you?', 'お元気ですか?', None, None, 1], [None, None, None, 'Ogenkidesuka?']]
28 | original pronounced [-1], translation pronounced is None
29 | - if length >3 and -2 element is None, that means cannot pronounce translation
30 |
31 | 4) お元気ですか? -> korean (origin: can pronounce, translation: can pronounce)
32 | [['잘 지내?', 'お元気ですか?', None, None, 0], [None, None, 'jal jinae?', 'Ogenkidesuka?']]
33 | original pronounced [-1], translation pronounced [-2]
34 | - if 1) is correct AND
35 |
36 | Logic:
37 | 1) If there is a translation AND len == 4, then there is origin language pronunciation at -1 index, else there isn't one
38 | 2) If there is a translation AND 2 index is not None, then there is a translation at 2 index, otherwise there isn't one
39 | """
40 |
41 |
42 | class GoogleTrans(ITranslator):
43 | def get_char_limit(self) -> int:
44 | return 5000
45 |
46 | def translate(self, text: List[str], to_lang: str) -> Iterator[Translated]:
47 | google_translated = GoogleTrans._do_translate(text, to_lang)
48 | for original, translated in zip(text, google_translated):
49 | yield Translated(original=original,
50 | translated=translated.text.strip(),
51 | pronounce_original=GoogleTrans._pronounce_origin(translated),
52 | pronounce_translated=GoogleTrans._pronounce_translated(translated))
53 |
54 | def detect_language(self, to_lang: str) -> Language:
55 | return next((Language(full, abb) for abb, full in googletrans.LANGUAGES.items()
56 | if to_lang == abb or to_lang == full), None)
57 |
58 | def get_supported(self) -> str:
59 | return ', '.join([f'{abb} - {full}' for abb, full in googletrans.LANGUAGES.items()])
60 |
61 | @staticmethod
62 | def _do_translate(text: List[str], to_lang: str) -> List[googletrans.models.Translated]:
63 | """
64 | Call google translate API to translate given text
65 |
66 | :param **kwargs:
67 | :param text: The source text(s) to be translated. Batch translation is supported via sequence input.
68 | :type text: UTF-8 :class:`str`; :class:`unicode`; string sequence (list, tuple, iterator, generator)
69 |
70 | :return: translated text in the same form it was provided
71 | """
72 | # Google API provider should allow new access every 1h, but if more translations need to be done,
73 | # a number of different country providers are given
74 | # E.g. from here https://sites.google.com/site/tech4teachlearn/googleapps/google-country-codes
75 | # But have to make sure the site actually loads first :)
76 |
77 | ending_formula = re.compile(r'translate\..*?\.(.+)$') # for for com, co.uk, lt or others
78 | provider_endings = (ending_formula.search(url).group(1) for url in googletrans.constants.DEFAULT_SERVICE_URLS)
79 | provider_base = 'translate.googleapis'
80 |
81 | for ending in provider_endings:
82 | provider = f'{provider_base}.{ending}'
83 | translator = googletrans.Translator(service_urls=[provider])
84 | try:
85 | return translator.translate(text, dest=to_lang)
86 | except AttributeError:
87 | logging.info(f'Provider "{provider}" got blocked, trying another one...')
88 | exit('No more providers left to try, try updating the provider list or wait 1h until you get unblocked.')
89 |
90 | @staticmethod
91 | def _pronounce_origin(translated: googletrans.models.Translated) -> str:
92 | # The only way we have origin pronunciation is when extra_data['translation'] contains at least two items:
93 | # 1) translation and 2) pronunciation. The latter must then contain 4 items, while the last item is the origin
94 | # translation. If the pronunciation only contains 3 items, then the 3rd item is the pronounced translation.
95 | expected = GoogleTrans._expected_pronounced(translated)
96 | if GoogleTrans._can_pronounce(expected) and GoogleTrans._can_pronounce_original(expected):
97 | return expected[-1]
98 | return translated.origin
99 |
100 | @staticmethod
101 | def _pronounce_translated(translated: googletrans.models.Translated) -> str:
102 | # When returning pronunciation of translated, the API returns pronunciation whenever one is available.
103 | # If however, it is not available it returns original text, while I would want it to return the translated text
104 | # instead, since that simply means that the text is already pronounced.
105 | expected = GoogleTrans._expected_pronounced(translated)
106 | if GoogleTrans._can_pronounce(expected) and GoogleTrans._can_pronounce_translated(expected):
107 | return expected[2]
108 | return translated.text
109 |
110 | @staticmethod
111 | def _expected_pronounced(translated: googletrans.models.Translated) -> List:
112 | return nth(translated.extra_data['translation'], -1)
113 |
114 | @staticmethod
115 | def _can_pronounce(pronounced: List) -> bool:
116 | return isinstance(nth(pronounced, -1), str)
117 |
118 | @staticmethod
119 | def _can_pronounce_original(pronounced: List) -> bool:
120 | return len(pronounced) == 4
121 |
122 | @staticmethod
123 | def _can_pronounce_translated(pronounced: List) -> bool:
124 | return pronounced[2] is not None
125 |
--------------------------------------------------------------------------------
/translatesubs/translators/itranslator.py:
--------------------------------------------------------------------------------
1 | from typing import List, Iterator
2 | from translatesubs.translators.translated import Translated
3 | from translatesubs.translators.language import Language
4 | from abc import ABC, abstractmethod
5 |
6 |
7 | class ITranslator(ABC):
8 | @abstractmethod
9 | def translate(self, text: List[str], to_lang: str) -> Iterator[Translated]:
10 | pass
11 |
12 | @abstractmethod
13 | def detect_language(self, to_lang: str) -> Language:
14 | pass
15 |
16 | @abstractmethod
17 | def get_supported(self) -> str:
18 | pass
19 |
20 | @abstractmethod
21 | def get_char_limit(self) -> int:
22 | pass
23 |
--------------------------------------------------------------------------------
/translatesubs/translators/language.py:
--------------------------------------------------------------------------------
1 | class Language:
2 | def __init__(self, full_name, abbreviation):
3 | self.full_name = full_name
4 | self.abbreviation = abbreviation
5 |
--------------------------------------------------------------------------------
/translatesubs/translators/translated.py:
--------------------------------------------------------------------------------
1 | class Translated:
2 | def __init__(self, original=None, translated=None, pronounce_original=None, pronounce_translated=None):
3 | self.original = original
4 | self.translated = translated
5 | self.pronounce_original = pronounce_original
6 | self.pronounce_translated = pronounce_translated
7 |
--------------------------------------------------------------------------------
/translatesubs/utils/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Montvydas/translatesubs/955cf46ead2657e6e4218de23efaa5a33e83f40a/translatesubs/utils/__init__.py
--------------------------------------------------------------------------------
/translatesubs/utils/constants.py:
--------------------------------------------------------------------------------
1 | from translatesubs.translators.googletrans import GoogleTrans
2 | from translatesubs.translators.google_trans_new import GoogleTransNew
3 |
4 |
5 | AVAILABLE_TRANSLATORS = {'googletrans': GoogleTrans, # Does not keep newlines for pronunciation only
6 | 'google_trans_new': GoogleTransNew} # Does not keep newlines
7 | TRANSLATORS_PRINT = ', '.join(AVAILABLE_TRANSLATORS.keys())
8 |
9 | ENDS_OF_SENTENCES = {
10 | 'Usual': '.!?"\')',
11 | 'Japanese': 'よねのさぞなか!。」…',
12 | }
13 |
14 | USE_DEFAULT_SEPS = 'default'
15 | DEFAULT_SEPS = [' $$$ ', ' ### ', ' ∞ ', '@@@', " ™ ", ' @@@ ', '$$$', '€€€', '££', ' ## ', '@@', '$$']
16 | DEFAULT_SEPS_PRINT = ', '.join((f'\"{sep}\"' for sep in DEFAULT_SEPS))
17 |
18 | SEP_MAX_LENGTH = 7
19 |
20 | SUB_FORMATS = ('srt', 'ass', 'ssa', 'mpl2', 'tmp', 'vtt', 'microdvd')
21 |
--------------------------------------------------------------------------------
/translatesubs/utils/tools.py:
--------------------------------------------------------------------------------
1 | def flatten(complex_list):
2 | return [inner for outer in complex_list for inner in outer]
3 |
4 |
5 | def nth_only_positive_index(lst, index, default=None):
6 | return (lst[index:index + 1] + [default])[0]
7 |
8 |
9 | def nth(lst, index, default=None):
10 | try:
11 | return lst[index]
12 | except IndexError:
13 | return default
14 |
--------------------------------------------------------------------------------
/truncated.ass:
--------------------------------------------------------------------------------
1 | [Script Info]
2 | Title: [Erai-raws] English (US)
3 |
4 | ScriptType: v4.00+
5 | ScaledBorderAndShadow: yes
6 | Collisions: Normal
7 | PlayResX: 640
8 | PlayResY: 360
9 | Timer: 0.0000
10 | WrapStyle: 0
11 |
12 | [V4+ Styles]
13 | Format: Name,Fontname,Fontsize,PrimaryColour,SecondaryColour,OutlineColour,BackColour,Bold,Italic,Underline,Strikeout,ScaleX,ScaleY,Spacing,Angle,BorderStyle,Outline,Shadow,Alignment,MarginL,MarginR,MarginV,Encoding
14 | Style: Default,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,0010,0010,0010,1
15 | Style: volley-main,Trebuchet MS,25,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,1,2,0020,0020,0015,0
16 | Style: volley-main-top,Trebuchet MS,25,&H00FFFFFF,&H000000FF,&H001E0200,&H00000000,0,0,0,0,100,100,0,0,1,2,1,8,0010,0010,0017,0
17 | Style: volley-internal,Trebuchet MS,25,&H00FFFFFF,&H000000FF,&H001E0200,&H00000000,0,-1,0,0,100,100,0,0,1,2,1,2,0010,0010,0015,0
18 | Style: volley-internal-top,Trebuchet MS,25,&H00FFFFFF,&H000000FF,&H001E0200,&H00000000,0,-1,0,0,100,100,0,0,1,2,1,8,0010,0010,0017,0
19 | Style: volley-overlap,Trebuchet MS,25,&H00BAFCF3,&H000000FF,&H001E0200,&H00000000,0,0,0,0,100,100,0,0,1,2,1,2,0010,0010,0015,0
20 | Style: volley-narration,Trebuchet MS,25,&H00FFFFFF,&H000000FF,&H00000026,&H00000000,0,-1,0,0,100,100,0,0,1,2,1,8,0020,0020,0015,0
21 | Style: volley-internaloverlap,Trebuchet MS,25,&H00BAFCF3,&H000000FF,&H001E0200,&H00000000,0,-1,0,0,100,100,0,0,1,2,1,2,0010,0010,0015,0
22 | Style: volley-flashback,Trebuchet MS,25,&H00FFFFFF,&H000000FF,&H004D0000,&H00000000,0,0,0,0,100,100,0,0,1,2,1,2,0010,0010,0015,0
23 | Style: volley-flashbackinternal,Trebuchet MS,25,&H00FFFFFF,&H000000FF,&H004D0701,&H00000000,0,-1,0,0,100,100,0,0,1,2,1,2,0010,0010,0015,0
24 | Style: volley-flashbackoverlap,Trebuchet MS,25,&H00BAFCF3,&H000000FF,&H004D0701,&H00000000,0,0,0,0,100,100,0,0,1,2,1,2,0010,0010,0015,0
25 | Style: volley-show-title-top,Arial,60,&H00030302,&H000000FF,&H00C2D5D1,&H00222A17,-1,0,0,0,100,100,0,0,1,0,0,8,0020,0020,0040,0
26 | Style: volley-show-title-bottom,Arial,20,&H00030302,&H000000FF,&H00C2D5D1,&H00222A17,-1,0,0,0,100,100,0,0,1,2,0,2,0020,0020,0040,0
27 | Style: volley-ep-title,Times New Roman,22,&H00FFFFFF,&H000000FF,&H001D1D1D,&H001D1D1D,0,0,0,0,100,100,0,0,1,1,1,3,0005,0042,0052,0
28 | Style: volley-eyecatch-a,Verdana,30,&H00000000,&H000000FF,&H004341C5,&H00000A2D,-1,0,0,0,100,100,0,0,1,0,0,1,0450,0020,0084,0
29 | Style: volley-eyecatch-b,Verdana,14,&H000800CD,&H000000FF,&H00000000,&H00000A2D,-1,-1,0,0,100,100,0,0,1,1,0,3,0020,0143,0020,0
30 | Style: volley-eyecatch-c,Verdana,30,&H00000000,&H000000FF,&H004341C5,&H00000A2D,-1,0,0,0,100,100,0,0,1,0,0,9,0020,0070,0070,0
31 | Style: volley-eyecatch-d,Verdana,14,&H000800CD,&H000000FF,&H00000000,&H00000A2D,-1,-1,0,0,100,100,0,0,1,1,0,7,0275,0143,0050,0
32 | Style: volley-preview,Trebuchet MS,25,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,-1,0,0,100,100,0,0,1,0,0,8,0040,0020,0130,0
33 | Style: volley-next-ep-title,Times New Roman,20,&H00FFFFFF,&H000000FF,&H00000000,&H00101011,-1,0,0,0,100,100,0,0,1,1,1,3,0000,0038,0055,0
34 | Style: scoreboard,Trebuchet MS,20,&H00363634,&H000000FF,&H002C2C2C,&H006F808B,-1,0,0,0,100,100,0,-16.5,1,0,0,7,0220,0020,0125,0
35 | Style: scoreboard2,Trebuchet MS,14,&H00090B0A,&H000000FF,&H00E7ECEB,&H00000000,-1,0,0,0,100,100,0,-6.5,1,4,0,8,0060,0020,0127,0
36 | Style: scoreboard3,Trebuchet MS,15,&H00363634,&H000000FF,&H00E3E6E5,&H006F808B,-1,0,0,0,100,100,0,0,1,4,0,8,0020,0050,0111,0
37 | Style: scoreboard4,Trebuchet MS,20,&H00363634,&H000000FF,&H00E8EDEC,&H006F808B,-1,0,0,0,100,100,0,-7,1,4,0,8,0080,0020,0055,0
38 | Style: scoreboard5,Trebuchet MS,12,&H000C0E0E,&H000000FF,&H00E2E3E0,&H006F808B,-1,-1,0,0,100,100,0,7,1,2,0,8,0020,0045,0112,0
39 | Style: scoreboard6,Trebuchet MS,14,&H000C0E0E,&H000000FF,&H00E4E9E8,&H00000000,-1,0,0,0,100,100,0,-6.5,1,2,0,8,0090,0020,0125,0
40 | Style: scoreboard7,Trebuchet MS,14,&H000C0E0E,&H000000FF,&H00E5E6E4,&H006F808B,-1,0,0,0,100,100,0,0,1,0,0,8,0020,0020,0125,0
41 | Style: scoreboard8,Trebuchet MS,7,&H000C0E0E,&H000000FF,&H00E3EAE9,&H00000000,0,-1,0,0,100,100,0,20,1,3,0,1,0070,0055,0080,0
42 | Style: scoreboard9,Trebuchet MS,13,&H000C0E0E,&H000000FF,&H00E2E3E0,&H006F808B,-1,0,0,0,100,100,0,-11,1,0,0,7,0075,0020,0091,0
43 | Style: scoreboard10,Trebuchet MS,15,&H000C0E0E,&H000000FF,&H00E7ECEB,&H006F808B,-1,0,0,0,100,100,0,-11,1,0,0,7,0070,0020,0102,0
44 | Style: scoreboard11,Trebuchet MS,10,&H000C0E0E,&H000000FF,&H00E3EAE9,&H00000000,-1,0,0,0,100,100,0,2,1,4,0,9,0060,0080,0166,0
45 | Style: scoreboard13,Trebuchet MS,15,&H00363634,&H000000FF,&H00E8EAEC,&H006F808B,-1,0,0,0,100,100,0,0,1,4,0,8,0040,0020,0095,0
46 | Style: banner,Arial,18,&H00221D18,&H000000FF,&H00534CA6,&H00000000,-1,0,0,0,100,100,0,0,1,4,0,8,0020,0070,0030,0
47 | Style: poster-orange,Times New Roman,20,&H00342C1F,&H000000FF,&H003F79CB,&H004D2F3D,-1,0,0,0,100,100,0,0,1,2,0,9,0020,0240,0080,0
48 | Style: poster-lower,Times New Roman,10,&H00494949,&H000000FF,&H00D7D7D7,&H005644C4,-1,0,0,0,100,100,0,0,1,4,0,1,0030,0020,0020,0
49 | Style: class,Arial,24,&H00524E48,&H000000FF,&H00EEEEEE,&H00000000,-1,0,0,0,100,100,0,0,1,4,0,8,0030,0000,0055,0
50 | Style: jacket,Times New Roman,10,&H00B6B5B3,&H000000FF,&H002D2B2A,&H005644C4,-1,0,0,0,100,100,0,0,1,4,0,2,0020,0470,0120,0
51 | Style: jacket2,Times New Roman,15,&H0033323E,&H000000FF,&H00B5B3C6,&H005644C4,-1,0,0,0,100,100,0,0,1,4,0,2,0020,0150,0120,0
52 | Style: jacket3,Times New Roman,7,&H00ABA9A7,&H000000FF,&H0031302B,&H005644C4,-1,0,0,0,100,100,0,0,1,4,0,5,0020,0280,0020,0
53 | Style: jacket4,Times New Roman,17,&H003C4042,&H000000FF,&H00E1E7E8,&H005644C4,-1,0,0,0,100,100,0,0,1,4,0,5,0020,0270,0065,0
54 | Style: shirt,Times New Roman,22,&H000B0B09,&H000000FF,&H00365047,&H00264474,-1,0,0,0,100,100,0,0,1,4,0,8,0020,0040,0120,0
55 | Style: shirt1,Times New Roman,22,&H00221A13,&H000000FF,&H00BCA77A,&H00264474,-1,0,0,0,100,100,0,0,1,4,0,8,0040,0020,0120,0
56 | Style: shirt3,Times New Roman,20,&H00DBDADD,&H000000FF,&H002F2E30,&H006F808B,-1,0,0,0,100,100,0,0,1,0,0,8,0020,0035,0165,0
57 | Style: shirt4,Times New Roman,20,&H00DBDADD,&H000000FF,&H002F2E30,&H006F808B,-1,-1,0,0,100,100,0,20,1,0,0,8,0150,0020,0130,0
58 | Style: shop,Times New Roman,18,&H00333D33,&H000000FF,&H002B2B24,&H00000000,-1,0,0,0,100,100,0,0,1,4,0,8,0020,0020,0050,0
59 | Style: notepad,Arial,12,&H00404040,&H000000FF,&H00ECECEC,&H005C574B,-1,0,0,0,100,100,0,0,1,4,0,5,0020,0020,0020,0
60 | Style: notepad2,Arial,15,&H00383838,&H000000FF,&H00E9E9E9,&H005C574B,0,0,0,0,100,100,0,0,1,4,0,8,0020,0020,0020,0
61 | Style: fly,Times New Roman,65,&H00E7EBDB,&H000000FF,&H002D2625,&H005C574B,-1,0,0,0,100,100,0,0,1,0,0,7,0040,0020,0120,0
62 | Style: fly1,Times New Roman,55,&H00E1E1E1,&H000000FF,&H002D2625,&H005C574B,-1,0,0,0,100,100,0,0,1,0,0,8,0060,0020,0080,0
63 | Style: fly2,Times New Roman,12,&H00EDEFE3,&H000000FF,&H0036302C,&H006F808B,-1,0,0,0,100,100,0,0,1,4,0,3,0020,0080,0030,0
64 | Style: fly3,Times New Roman,18,&H00E3E1DF,&H000000FF,&H00292524,&H006F808B,-1,0,0,0,100,100,0,0,1,0,0,8,0020,0038,0135,0
65 | Style: fly4,Times New Roman,17,&H00EDEFE3,&H000000FF,&H0036302C,&H006F808B,-1,0,0,0,100,100,0,0,1,0,0,3,0020,0100,0020,0
66 | Style: fly5,Times New Roman,12,&H00A39FA0,&H000000FF,&H00303131,&H006F808B,-1,0,0,0,100,100,0,0,1,4,0,9,0020,0020,0130,0
67 | Style: Connect,Times New Roman,45,&H00303136,&H000000FF,&H002D2625,&H005C574B,-1,0,0,0,100,100,0,0,1,0,0,8,0100,0020,0020,0
68 | Style: white,Verdana,13,&H00000000,&H000000FF,&H00BBC2C2,&H00000000,-1,0,0,0,100,100,0,0,1,1,1,2,0020,0400,0030,0
69 | Style: white2,Verdana,25,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,1,2,2,0020,0020,0070,0
70 | Style: tourney,Arial,6,&H00757271,&H000000FF,&H00DFDCD8,&H00505B5E,-1,0,0,0,100,100,0,0,1,2,0,1,0177,0020,0085,0
71 | Style: sub-arena,Arial,13,&H00131313,&H000000FF,&H00FFFFFF,&H00D1FDFF,-1,0,0,0,100,100,0,0,1,4,0,8,0220,0020,0163,0
72 | Style: board,Arial,16,&H003C4140,&H000000FF,&H00F1F1F1,&H006F808B,-1,0,0,0,100,100,0,-30,1,4,0,5,0020,0020,0100,0
73 | Style: hotel1,Verdana,24,&H00122657,&H000000FF,&H00DCE6E8,&H00D1FDFF,-1,0,0,0,100,100,0,-11,1,4,0,8,0080,0020,0075,0
74 | Style: hotel2,Verdana,10,&H00585C5E,&H000000FF,&H00A3A2A0,&H00303340,-1,0,0,0,100,100,0,0,1,3,0,7,0250,0220,0070,0
75 | Style: memories1,Times New Roman,17,&H0063D1DA,&H000000FF,&H00313433,&H006F808B,-1,0,0,0,100,100,0,0,1,4,0,2,0020,0200,0050,0
76 | Style: poster,Arial,11,&H009AA1A7,&H000000FF,&H00F3F8FE,&H00B1B2BA,-1,0,0,0,100,100,0,0,1,4,0,4,0020,0020,0020,0
77 | Style: phone1,Trebuchet MS,17,&H004B4345,&H000000FF,&H00DFDBD9,&H00D1FDFF,-1,0,0,0,100,100,0,19,1,4,0,8,0020,0020,0050,0
78 | Style: phone2,Trebuchet MS,10,&H00656162,&H000000FF,&H00686159,&H006F808B,-1,0,0,0,100,100,0,-15,1,0,0,8,0020,0020,0140,0
79 | Style: chance,Arial,25,&H000B0B09,&H000000FF,&H005E32C9,&H00BAE9FA,-1,0,0,0,100,100,0,0,1,4,0,8,0020,0020,0015,0
80 | Style: mag,Arial,25,&H00DFCEEE,&H000000FF,&H005501B0,&H0009347C,-1,0,0,0,100,100,0,0,1,4,0,6,0000,0020,0020,0
81 | Style: atsu,Verdana,17,&H005501B0,&H000000FF,&H00D3CFCE,&H0009347C,-1,0,0,0,100,100,0,0,1,4,0,5,0020,0080,0050,0
82 | Style: osamu,Verdana,17,&H004669D7,&H000000FF,&H00553522,&H0009347C,-1,0,0,0,100,100,0,0,1,4,0,9,0020,0150,0150,0
83 | Style: fans,Trebuchet MS,15,&H004A1F3B,&H000000FF,&H00D8D4D6,&H004D2F3D,-1,0,0,0,100,100,0,0,1,4,0,5,0170,0020,0132,0
84 | Style: fans2,Trebuchet MS,15,&H0059D5CD,&H000000FF,&H00382A1C,&H004D2F3D,-1,0,0,0,100,100,0,0,1,4,0,2,0020,0020,0090,0
85 | Style: fans3,Trebuchet MS,15,&H009859A9,&H000000FF,&H00382A1C,&H004D2F3D,-1,0,0,0,100,100,0,0,1,4,0,3,0020,0020,0095,0
86 | Style: fans4,Trebuchet MS,25,&H0055E5C7,&H000000FF,&H00382A1C,&H004D2F3D,-1,0,0,0,100,100,0,0,1,4,0,1,0020,0020,0020,0
87 | Style: fans5,Trebuchet MS,23,&H00B031D2,&H000000FF,&H00382A1C,&H004D2F3D,-1,0,0,0,100,100,0,0,1,4,0,3,0020,0070,0110,0
88 | Style: charm,Arial,17,&H00B7B0B1,&H000000FF,&H002A1070,&H00FFFFFE,-1,0,0,0,100,100,0,0,1,4,0,5,0020,0020,0077,0
89 | Style: sign_1390_6_Tsubakihara_Kara,Arial,16,&H003C4140,&H000000FF,&H00F1F1F1,&H006F808B,-1,0,0,0,100,100,0,0,1,4,0,7,0030,0030,0020,0
90 | Style: sign_6764_38_Aran,Verdana,40,&H001B1B1B,&H000000FF,&H00D5D5D5,&H00000000,-1,0,0,0,100,100,0,0,1,4,0,2,0030,0030,0020,0
91 | Style: sign_17448_157_Karasuno,Times New Roman,25,&H007B6F78,&H000000FF,&H0048212C,&H00000000,-1,0,0,0,100,100,0,0,1,4,0,2,0030,0225,0305,0
92 | Style: sign_17477_158_Karasuno_Taiko,Times New Roman,37,&H00111113,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,0,0,1,0365,0030,0275,0
93 | Style: sign_18757_172_Nohebi_Academy_V,Arial,13,&H000C0206,&H000000FF,&H00A2A2A2,&H00000000,-1,0,0,0,100,100,0,0,1,1,0,2,0265,0030,0080,0
94 | Style: sign_5051_39_Fire_Hydrant_Sto,Arial,8,&H005142B1,&H000000FF,&H00BACBD4,&H006F808B,-1,0,0,0,100,100,0,0,1,4,0,7,0030,0030,0020,0
95 | Style: sign_119_1_Court_,Trebuchet MS,17,&H00111113,&H000000FF,&H00F5F5F5,&H00000000,-1,0,0,0,100,100,0,0,1,4,0,7,0230,0030,0020,0
96 | Style: sign_816_9_Keep_Standing_Ba,Times New Roman,17,&H006D3B31,&H000000FF,&H00DCE1E7,&H006F808B,-1,0,0,0,100,100,0,0,1,4,0,2,0030,0030,0020,0
97 | Style: sign_5627_49_Well__think_abou,Verdana,20,&H00CDD8EF,&H000000FF,&H00182232,&H00000000,-1,0,0,0,100,100,0,0,1,4,0,8,0030,0300,0020,0
98 | Style: sign_6360_59_Vending_Machine_,Arial,9,&H009D7960,&H000000FF,&H00D5CFCA,&H006F808B,-1,0,0,0,100,100,0,0,1,4,0,2,0030,0030,0020,0
99 | Style: sign_8942_98_Incomprehensible,Arial,12,&H00F0F0F0,&H000000FF,&H00070A08,&H00000000,0,0,0,0,100,100,0,0,1,4,0,1,0030,0030,0020,0
100 | Style: connect-banner,Times New Roman,20,&H00252628,&H000000FF,&H004C32C9,&H00505B5E,-1,0,0,0,100,100,0,0,1,4,0,3,0020,0100,0040,0
101 | Style: connect-banner2,Times New Roman,35,&H00252628,&H000000FF,&H004C32C9,&H00505B5E,-1,0,0,0,100,100,0,0,1,4,0,5,0100,0020,0040,0
102 | Style: sign_29078_298_Boys__High_Schoo,Trebuchet MS,35,&H00111113,&H000000FF,&H00CBCBCB,&H00000000,-1,0,0,0,100,100,0,0,1,4,0,3,0030,0030,0020,0
103 |
104 | [Events]
105 | Format: Layer,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text
106 | Dialogue: 0,0:00:17.26,0:00:18.28,volley-main,Guy,0000,0000,0000,,Yeah.
107 | Dialogue: 0,0:00:18.91,0:00:22.08,Connect,Sign,0000,0000,0000,,Connect
108 | Dialogue: 0,0:00:19.49,0:00:20.96,volley-main,Mika,0000,0000,0000,,Nekoma?
109 | Dialogue: 0,0:00:20.96,0:00:22.08,volley-main,Kuro,0000,0000,0000,,Left!
110 | Dialogue: 0,0:00:25.32,0:00:26.25,volley-main,Yaku,0000,0000,0000,,Kenma!
--------------------------------------------------------------------------------
/version.txt:
--------------------------------------------------------------------------------
1 | 0.2.4
--------------------------------------------------------------------------------