Autosub

生成*.srt格式字幕和json

安装ffmpeg
[sudo] apt-get install ffmpeg
安装python
[sudo] apt-get install python-pip
安装autosub
pip install autosub
音频转字幕
已有视频demo.mp4(带音频) 中文语音生成中文字幕
autosub -S zh-CN -D zh-CN demo.mp4
-S源语言
-D输出字幕语言

语言支持列表
af Afrikaans
ar Arabic
az Azerbaijani
be Belarusian
bg Bulgarian
bn Bengali
bs Bosnian
ca Catalan
ceb Cebuano
cs Czech
cy Welsh
da Danish
de German
el Greek
en English
eo Esperanto
es Spanish
et Estonian
eu Basque
fa Persian
fi Finnish
fr French
ga Irish
gl Galician
gu Gujarati
ha Hausa
hi Hindi
hmn Hmong
hr Croatian
ht Haitian Creole
hu Hungarian
hy Armenian
id Indonesian
ig Igbo
is Icelandic
it Italian
iw Hebrew
ja Japanese
jw Javanese
ka Georgian
kk Kazakh
km Khmer
kn Kannada
ko Korean
la Latin
lo Lao
lt Lithuanian
lv Latvian
mg Malagasy
mi Maori
mk Macedonian
ml Malayalam
mn Mongolian
mr Marathi
ms Malay
mt Maltese
my Myanmar (Burmese)
ne Nepali
nl Dutch
no Norwegian
ny Chichewa
pa Punjabi
pl Polish
pt Portuguese
ro Romanian
ru Russian
si Sinhala
sk Slovak
sl Slovenian
so Somali
sq Albanian
sr Serbian
st Sesotho
su Sudanese
sv Swedish
sw Swahili
ta Tamil
te Telugu
tg Tajik
th Thai
tl Filipino
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
yi Yiddish
yo Yoruba
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
zu Zulu
源语言与输出语言不同将自动翻译(可能需要Google Translate API)
autosub -S zh-CN -D en -K Google_Translate_API demo.mp4
进阶
autosub -h
usage: autosub [-h] [-C CONCURRENCY] [-o OUTPUT] [-F FORMAT] [-S SRC_LANGUAGE]
[-D DST_LANGUAGE] [-K API_KEY] [–list-formats]
[–list-languages]
[source_path]

positional arguments:
source_path Path to the video or audio file to subtitle

optional arguments:
-h, --help show this help message and exit \\帮助
-C CONCURRENCY, --concurrency CONCURRENCY
Number of concurrent API requests to make \\API发送并发数
-o OUTPUT, --output OUTPUT
Output path for subtitles (by default, subtitles are
saved in the same directory and name as the source
path) \\指定字幕文件路径
-F FORMAT, --format FORMAT
Destination subtitle format \\字幕格式
-S SRC_LANGUAGE, --src-language SRC_LANGUAGE
Language spoken in source file \\源文件语言
-D DST_LANGUAGE, --dst-language DST_LANGUAGE
Desired language for the subtitles \\输出字幕语言
-K API_KEY, --api-key API_KEY
The Google Translate API key to be used. (Required for
subtitle translation) \\Google Translate API翻译接口
–list-formats List all available subtitle formats \\列出所有可用字幕格式
–list-languages List all available source/destination languages \\列出所有支持的语言