Skip to content

Commit 2d1ce83

Browse files
committed
Merge branch 'dev' into alpha
2 parents db0850c + b1ae5a0 commit 2d1ce83

21 files changed

+765
-368
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ A clear and concise description of what the bug is.
1414

1515
**To Reproduce**
1616
Steps to reproduce the behavior:
17+
1718
1. Command line arguments you are using.
18-
2. A complete copy of command line output of the autosub. You can use `Ctrl-A` and `Ctrl-C` to copy all of them. Use the following markdown code block syntax is recommended.
19+
2. A complete copy of command line output of the autosub. You can use `Ctrl-A` and `Ctrl-C` to copy all of them. Use the following markdown code block syntax is recommended. Copy them into the place between \`\`\`.
1920

2021
```
2122
```
2223

23-
3. etc.
24+
3. etc.
2425

2526
**Expected behavior**
2627
A clear and concise description of what you expected to happen.
@@ -29,9 +30,10 @@ A clear and concise description of what you expected to happen.
2930
If applicable, add screenshots to help explain your problem. But it is not recommended using screenshots to demonstrate the commandline output unless you think it really matters.
3031

3132
**Environment (please complete the following information):**
32-
- OS: [e.g. windows]
33-
- Python Version: [e.g. Python 2.7]
34-
- Autosub Version: [e.g. 0.4.0]
33+
34+
- OS: [e.g. windows]
35+
- Python Version: [e.g. Python 2.7]
36+
- Autosub Version: [e.g. 0.4.1-alpha/0.5.4-alpha Nuitka windows release]
3537

3638
**Additional context** (Optional)
3739
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/bug_report.zh-Hans.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ assignees: ''
1414

1515
**复现问题**
1616
复现问题的步骤:
17+
1718
1. 你使用的命令行参数。
18-
2. 一份完整的autosub命令行输出。你可以使用`Ctrl-A``Ctrl-C`去复制所有输出。推荐使用以下的代码块markdown语法。
19+
2. 一份完整的autosub命令行输出。你可以使用`Ctrl-A``Ctrl-C`去复制所有输出。推荐使用以下的代码块markdown语法,将代码块复制到\`\`\`\`\`\`之间即可
1920

2021
```
2122
```
@@ -29,9 +30,10 @@ assignees: ''
2930
合适的话可以提供用以描述问题的截图。但是不推荐用截图来展示命令行输出,除非你真的认为这很有必要。
3031

3132
**操作环境(请提供以下完整数据):**
32-
- 操作系统: [譬如 windows]
33-
- Python版本: [譬如 Python 2.7]
34-
- Autosub版本: [譬如 0.4.0]
33+
34+
- 操作系统: [譬如 windows]
35+
- Python版本: [譬如 Python 2.7]
36+
- Autosub版本: [譬如 0.4.1-alpha或0.5.4-alpha Nuitka windows发布版]
3537

3638
**额外信息**(可选)
3739
任何其他的能描述问题的信息。

CHANGELOG.md

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,69 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## TOC
1111

12+
- [Unreleased](#unreleased)
13+
- [Added](#addedunreleased)
14+
- [Changed](#changedunreleased)
15+
- [0.5.6-alpha - 2020-03-20](#056-alpha---2020-03-20)
16+
- [Added](#added056-alpha)
17+
- [Changed](#changed056-alpha)
18+
- [Deprecated](#deprecated056-alpha)
19+
- [Fixed](#fixed056-alpha)
1220
- [0.5.5-alpha - 2020-03-04](#055-alpha---2020-03-04)
1321
- [Added](#added055-alpha)
14-
- [Changed](#changed055-alpha)
22+
- [Fixed](#fixed055-alpha)
1523
- [0.5.4-alpha - 2020-01-31](#054-alpha---2020-01-31)
1624
- [Added](#added054-alpha)
17-
- [Changed](#changed054-alpha)
25+
- [Removed](#removed054-alpha)
26+
- [Fixed](#fixed054-alpha)
1827
- [0.5.3-alpha - 2019-12-30](#053-alpha---2019-12-30)
19-
- [Changed](#changed053-alpha)
28+
- [Fixed](#fixed053-alpha)
2029
- [0.5.2-alpha - 2019-11-05](#052-alpha---2019-11-05)
2130
- [Added](#added052-alpha)
22-
- [Changed](#changed052-alpha)
31+
- [Fixed](#fixed052-alpha)
2332
- [0.5.1-alpha - 2019-08-02](#051-alpha---2019-08-02)
2433
- [Added](#added051-alpha)
25-
- [Changed](#changed051-alpha)
34+
- [Fixed](#fixed051-alpha)
2635
- [0.5.0-alpha - 2019-07-27](#050-alpha---2019-07-27)
2736
- [Added](#added050-alpha)
2837
- [Changed](#changed050-alpha)
38+
- [Fixed](#fixed050-alpha)
2939
- [0.4.1-alpha - 2019-07-11](#041-alpha---2019-07-11)
3040
- [Added](#added041-alpha)
3141
- [Changed](#changed041-alpha)
42+
- [Fixed](#fixed041-alpha)
3243
- [0.4.0-alpha - 2019-02-17](#040-alpha---2019-02-17)
33-
- [Changed](#changed040-alpha)
44+
- [Fixed](#fixed040-alpha)
3445

3546
Click up arrow to go back to TOC.
3647

48+
### [Unreleased]
49+
50+
#### Added(Unreleased)
51+
52+
#### Changed(Unreleased)
53+
54+
### [0.5.6-alpha] - 2020-03-20
55+
56+
#### Added(0.5.6-alpha)
57+
58+
- Add extra environment variables check when finding dependencies. [issue #91](https://github.com/BingLingGroup/autosub/issues/91)
59+
- Add arguments parser input when open it without arguments. [issue #92](https://github.com/BingLingGroup/autosub/issues/92)
60+
- Add subtitles processing when not input `-SRC`.
61+
62+
#### Changed(0.5.6-alpha)
63+
64+
- Change option `-sml` into `-nsml`.
65+
- Change defaults for Auditok.
66+
67+
#### Fixed(0.5.6-alpha)
68+
69+
- Fix Google Speech-to-Text API empty result response bug. [issue #89](https://github.com/BingLingGroup/autosub/issues/89)
70+
71+
#### Deprecated(0.5.6-alpha)
72+
73+
- Deprecate Python 2.7 support.
74+
3775
### [0.5.5-alpha] - 2020-03-04
3876

3977
#### Added(0.5.5-alpha)
@@ -43,29 +81,34 @@ Click up arrow to go back to TOC.
4381
- Add exception when receiving error from [Google-Speech-v2](https://github.com/gillesdemey/google-speech-v2).
4482
- Add Nuitka compatibility codes to stop program compiled by Nuitka when using Google Cloud service account credentials. [Nuitka pkg_resources.DistributionNotFound error](https://github.com/Nuitka/Nuitka/issues/146)
4583

46-
#### Changed(0.5.5-alpha)
84+
#### Fixed(0.5.5-alpha)
4785

4886
- Fix high memory/RAM usage partially by terminating child processes, lowering default multiprocessing counts and using `gc.collect(0)`. [issue #67](https://github.com/BingLingGroup/autosub/issues/67), [issue #74](https://github.com/BingLingGroup/autosub/issues/74)
4987
- Fix dependency finding issue. [issue #82](https://github.com/BingLingGroup/autosub/issues/82)
5088
- Fix ass override tags translation issue. [issue #79](https://github.com/BingLingGroup/autosub/issues/79)
5189

90+
<escape><a href = "#TOC">&nbsp;&nbsp;</a></escape>
91+
5292
### [0.5.4-alpha] - 2020-01-31
5393

5494
#### Added(0.5.4-alpha)
5595

5696
- Add basic Google Cloud Speech-to-Text support. [issue #10](https://github.com/BingLingGroup/autosub/issues/10)
5797
- Add more bilingual subtitles formats output support. [issue #72](https://github.com/BingLingGroup/autosub/issues/72)
5898

59-
#### Changed(0.5.4-alpha)
99+
#### Removed(0.5.4-alpha)
60100

61-
- Fix output format limits when input is a subtitles file.
62101
- Remove gtransv2 support.
63102

103+
#### Fixed(0.5.4-alpha)
104+
105+
- Fix output format limits when input is a subtitles file.
106+
64107
<escape><a href = "#TOC">&nbsp;&nbsp;</a></escape>
65108

66109
### [0.5.3-alpha] - 2019-12-30
67110

68-
#### Changed(0.5.3-alpha)
111+
#### Fixed(0.5.3-alpha)
69112

70113
- Fix excessive transcoding time issue. [pull request #66](https://github.com/BingLingGroup/autosub/pull/66)
71114
- Fix Auditok option issues. [issue #70](https://github.com/BingLingGroup/autosub/issues/70)
@@ -79,7 +122,7 @@ Click up arrow to go back to TOC.
79122

80123
- Add issue templates.
81124

82-
#### Changed(0.5.2-alpha)
125+
#### Fixed(0.5.2-alpha)
83126

84127
- Fix last row of empty translation text missing issue. [issue #62](https://github.com/BingLingGroup/autosub/issues/62)
85128
- Fix executable file detection problem in the current directory.
@@ -92,7 +135,7 @@ Click up arrow to go back to TOC.
92135

93136
- Add translation source lang code auto match.
94137

95-
#### Changed(0.5.1-alpha)
138+
#### Fixed(0.5.1-alpha)
96139

97140
- Fix method list_to_googletrans index error bug. [issue #48](https://github.com/BingLingGroup/autosub/issues/48)
98141
- Fix unix subprocess.check_output compatibility. [issue #47](https://github.com/BingLingGroup/autosub/issues/47)
@@ -149,14 +192,17 @@ Click up arrow to go back to TOC.
149192
- Refactor internal regions unit to millisecond. [issue #23](https://github.com/BingLingGroup/autosub/issues/23)
150193
- Refactor speech regions detection by using auditok. [issue #27](https://github.com/BingLingGroup/autosub/issues/27)
151194
- Refactor generate_subtitles into 3 parts. [issue #24](https://github.com/BingLingGroup/autosub/issues/24)
152-
- [issue #8](https://github.com/BingLingGroup/autosub/issues/8)
153-
- Fix python3 compatibility issues.
154-
- Fix Nuitka build after updating Nuitka to 0.6.4(Environment Anaconda2 python3.5).
155195
- Refactor api_gen_text to 2 parts. One is speech_to_text. Another is text_translation. [issue #33](https://github.com/BingLingGroup/autosub/issues/33)
156196
- Refactor txt output. Now txt can output regions.
157-
- Fix vtt output replacing all commas to dots issues.
158197
- Refactor list_to_sub_str. [issue #37](https://github.com/BingLingGroup/autosub/issues/37)
159198

199+
#### Fixed(0.5.0-alpha)
200+
201+
- Fix vtt output replacing all commas to dots issues.
202+
- [issue #8](https://github.com/BingLingGroup/autosub/issues/8)
203+
- Fix python3 compatibility issues.
204+
- Fix Nuitka build after updating Nuitka to 0.6.4(Environment Anaconda2 python3.5).
205+
160206
<escape><a href = "#TOC">&nbsp;&nbsp;</a></escape>
161207

162208
### [0.4.1-alpha] - 2019-07-11
@@ -171,16 +217,19 @@ Click up arrow to go back to TOC.
171217

172218
#### Changed(0.4.1-alpha)
173219

174-
- Fix vague language codes caused wrong recognition result. [agermanidis/autosub pull request #136](https://github.com/agermanidis/autosub/pull/136)
175220
- Change docs.
176221

222+
#### Fixed(0.4.1-alpha)
223+
224+
- Fix vague language codes caused wrong recognition result. [agermanidis/autosub pull request #136](https://github.com/agermanidis/autosub/pull/136)
225+
177226
<escape><a href = "#TOC">&nbsp;&nbsp;</a></escape>
178227

179228
### [0.4.0-alpha] - 2019-02-17
180229

181230
[0.4.0-alpha release](https://github.com/BingLingGroup/autosub/releases/tag/0.4.0-alpha)
182231

183-
#### Changed(0.4.0-alpha)
232+
#### Fixed(0.4.0-alpha)
184233

185234
- Fix several issues. [agermanidis/autosub pull request #128](https://github.com/agermanidis/autosub/pull/128) by [@iWangJiaxiang](https://github.com/iWangJiaxiang)
186235
- Fix "ffmpeg.exe" causes "Dependency not found: ffmpeg" on Windows.
@@ -190,7 +239,8 @@ Click up arrow to go back to TOC.
190239

191240
<escape><a href = "#TOC">&nbsp;&nbsp;</a></escape>
192241

193-
[Unreleased]: https://github.com/BingLingGroup/autosub/compare/0.5.5-alpha...HEAD
242+
[Unreleased]: https://github.com/BingLingGroup/autosub/compare/0.5.6-alpha...HEAD
243+
[0.5.6-alpha]: https://github.com/BingLingGroup/autosub/compare/0.5.5-alpha...0.5.6-alpha
194244
[0.5.5-alpha]: https://github.com/BingLingGroup/autosub/compare/0.5.4-alpha...0.5.5-alpha
195245
[0.5.4-alpha]: https://github.com/BingLingGroup/autosub/compare/0.5.3-alpha...0.5.4-alpha
196246
[0.5.3-alpha]: https://github.com/BingLingGroup/autosub/compare/0.5.2-alpha...0.5.3-alpha

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ This repo has a different license from [the original repo](https://github.com/ag
7676
Autosub depends on these third party softwares or Python site-packages. Much appreciation to all of these projects.
7777

7878
- [ffmpeg](https://ffmpeg.org/)
79+
- [ffprobe](https://ffmpeg.org/ffprobe.html)
7980
- [auditok](https://github.com/amsehili/auditok)
8081
- [pysubs2](https://github.com/tkarabela/pysubs2)
8182
- [py-googletrans](https://github.com/ssut/py-googletrans)
@@ -96,6 +97,13 @@ After autosub-0.4.0, all of the codes is compatible with both Python 2.7 and Pyt
9697

9798
About the dependencies installation. If you install autosub by pip, ffmpeg and ffmpeg-normalize won't be installed together not like the Python site-packages already listed on the `setup.py` or `requirements.txt`. You need to install them separately. But of course they are optional. They aren't necessary if you only use autosub to translate your subtitles.
9899

100+
ffmpeg, ffprobe, ffmpeg-normalize need to be put on one of these places to let the autosub detect and use them. The following codes are in the [constants.py](autosub/constants.py). Priority is determined in order.
101+
102+
1. Set the following environment variables before running the program: `FFMPEG_PATH`, `FFPROBE_PATH` and `FFMPEG_NORMALIZE_PATH`. It will override the ones located at the environment variable `PATH`. This will be helpful if you don't want to use the one in the `PATH`.
103+
2. Add them to the environment variable `PATH`. No need to worry about if using package manager to install such as using pip to install ffmpeg-normalize and using chocolatey to install ffmpeg.
104+
3. Add them to the same directory as the autosub executable.
105+
4. Add them to the current command line working directory.
106+
99107
About the git installation. If you don't want to install git to use pip [VCS](https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support) support to install python package or just confused with git environment variables, you can manually click that clone and download button to download the source code and use pip to install the source code [locally](https://pip.pypa.io/en/stable/reference/pip_install/#description) by input these commands.
100108

101109
```batch
@@ -157,6 +165,8 @@ You can just go to the [release page](https://github.com/BingLingGroup/autosub/r
157165

158166
Tips: `Shift - Right Click` is the keyboard shortcut for opening a Powershell on current directory. To open an exe at current directory, the format is like `.\autosub`.
159167

168+
Or you can just directly open it and input the args manually though I don't recommend doing this due to its less efficiency.
169+
160170
- The one without pyinstaller suffix is compiled by Nuitka. It's faster than the pyinstaller due to its compiling feature different from pyinstaller which just bundles the application.
161171
- ffmpeg and ffmpeg-normalize are also in the package. The original ffmpeg-normalize doesn't have a standalone version. The standalone version of ffmpeg-normalize is built separately. Codes are [here](https://github.com/BingLingGroup/ffmpeg-normalize).
162172
- If there's anything wrong on the both releases, or the package size and any other things are annoying you, you can just use the traditional pip installation method below.
@@ -260,13 +270,13 @@ To solve this problem, autosub uses [langcodes](https://github.com/LuminosoInsig
260270

261271
To manually match or see the full list of the lang codes, run the utility with the argument `-lsc`/`--list-speech-codes` and `-ltc`/ `--list-translation-codes`. Or open [constants.py](autosub/constants.py) and check.
262272

263-
To get a subtitles first line language, you can use `-dsl` to detect.
273+
To get the language of the first line of the subtitles file, you can use `-dsl` to detect.
264274

265275
- Currently, autosub allows to send the lang codes not from the `--list-speech-codes`, which means in this case the program won't stop.
266276

267277
- Though you can input the speech lang code whatever you want, need to point out that if not using the codes on the list but somehow the API accept it, [Google-Speech-v2](https://github.com/gillesdemey/google-speech-v2) recognizes your audio in the ways that depend on your IP address which is uncontrollable by yourself. This is a known issue and I ask for a [pull request](https://github.com/agermanidis/autosub/pull/136) in the original repo.
268278

269-
- On the other hand, [py-googletrans](https://github.com/ssut/py-googletrans) is stricter. When it receive a lang code not on its list, it will throw an exception. Of course it can be designed as a throw-catch code block and ask user to input once again but currently I don't add this support so an improper translation lang code input will stop the program running unless you use the best match method mentioned above.
279+
- On the other hand, [py-googletrans](https://github.com/ssut/py-googletrans) is stricter. When it receive a lang code not on its list, it will throw an exception and stop translation.
270280

271281
- Apart from the user input, another notable change is I split the `-S` option into two parts, `-S` and `-SRC`. `-S` option is for speech recognition lang code. `-SRC` is for translation source language. When not offering the arg of `-SRC`, autosub will automatically match the `-S` arg by using [langcodes](https://github.com/LuminosoInsight/langcodes) and get a best-match lang code for translation source language though [py-googletrans](https://github.com/ssut/py-googletrans) can auto-detect source language. Of course you can manually specify one by input `-SRC` option. `-D` is for translation destination language, still the same as before.
272282

autosub/__init__.py

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from __future__ import absolute_import, print_function, unicode_literals
88
import os
99
import gettext
10+
import sys
11+
import shlex
1012

1113
# Import third-party modules
1214
import pysubs2
@@ -35,7 +37,21 @@ def main(): # pylint: disable=too-many-branches, too-many-statements, too-many-
3537
Run autosub as a command-line program.
3638
"""
3739

38-
args = options.get_cmd_args()
40+
is_pause = False
41+
42+
try:
43+
input_main = raw_input
44+
except NameError:
45+
input_main = input
46+
47+
option_parser = options.get_cmd_parser()
48+
if len(sys.argv) > 1:
49+
args = option_parser.parse_args()
50+
else:
51+
option_parser.print_help()
52+
new_argv = input_main(_("\nInput args(without \"autosub\"): "))
53+
args = option_parser.parse_args(shlex.split(new_argv))
54+
is_pause = True
3955

4056
if args.https_proxy:
4157
os.environ['https_proxy'] = args.https_proxy
@@ -57,17 +73,14 @@ def main(): # pylint: disable=too-many-branches, too-many-statements, too-many-
5773
raise exceptions.AutosubException(_("\nAll works done."))
5874

5975
if not args.yes:
60-
try:
61-
input_m = raw_input
62-
except NameError:
63-
input_m = input
76+
input_m = input_main
6477
else:
6578
input_m = None
6679

6780
styles_list = []
68-
validate_result = cmdline_utils.validate_io(args, styles_list)
81+
result = cmdline_utils.validate_io(args, styles_list)
6982

70-
if validate_result == 0:
83+
if result:
7184
if not constants.FFMPEG_CMD:
7285
raise exceptions.AutosubException(
7386
_("Error: Dependency ffmpeg"
@@ -147,23 +160,30 @@ def main(): # pylint: disable=too-many-branches, too-many-statements, too-many-
147160
input_m=input_m,
148161
styles_list=styles_list)
149162

150-
elif validate_result == 1:
151-
cmdline_utils.validate_sp_args(args)
163+
else:
164+
result = cmdline_utils.validate_sp_args(args)
152165
fps = cmdline_utils.get_fps(args=args, input_m=input_m)
153-
cmdline_utils.sub_trans(args,
154-
input_m=input_m,
155-
fps=fps,
156-
styles_list=None)
166+
if result:
167+
cmdline_utils.sub_trans(args,
168+
input_m=input_m,
169+
fps=fps,
170+
styles_list=None)
171+
else:
172+
cmdline_utils.sub_conversion(
173+
args,
174+
input_m=input_m,
175+
fps=fps
176+
)
177+
178+
raise exceptions.AutosubException(_("\nAll works done."))
157179

158180
except KeyboardInterrupt:
159181
print(_("\nKeyboardInterrupt. Works stopped."))
160-
return 1
161182
except pysubs2.exceptions.Pysubs2Error:
162183
print(_("\nError: pysubs2.exceptions. Check your file format."))
163-
return 1
164184
except exceptions.AutosubException as err_msg:
165185
print(err_msg)
166-
return 0
167186

168-
print(_("\nAll works done."))
187+
if is_pause:
188+
input_main(_("Press Enter to exit..."))
169189
return 0

0 commit comments

Comments
 (0)