gptsubtitler
1.0.0
使用 AI 自动将任何语言的任何视频添加为您选择的语言的字幕。
使用型号:
使用的工具:
ffmpeg
如果您发现它有用或有教育意义,请不要忘记给存储库加注星标!
前:
之后(罗马尼亚语 - model_type=medium, language_model_type=base
):
使用pip
安装。
pip install gptsubtitler
安装ffmpeg
:
# Ubuntu or Debian
sudo apt update && sudo apt install ffmpeg
# MacOS
brew install ffmpeg
# Windows using Chocolatey https://chocolatey.org/
choco install ffmpeg
添加字幕并将其翻译为罗马尼亚语的示例用法:
命令行:
gptsubtitler soldier.mp4 --source_language en --target_language ro --captioning_model_type medium --language_model_type base
或者用Python
from gptsubtitler import Transcriber
# I strongly recommend using the "medium" model_type.
Transcriber . transcribe ( "soldier.mp4" , source_language = "en" , target_language = "ro" , captioning_model_type = "medium" , language_model_type = "base" )
如果您只想翻译一些文本,您还可以使用translator.py
中的Translator
类。
从英语翻译为罗马尼亚语的用法示例:
from gptsubtitler import Translator
print ( Translator . translate ( "Hi!" , target_language = "ro" , source_language = "en" ))
如果您已生成.srt
文件并且只想添加字幕:
from gptsubtitler import create_video_with_subtitles
create_video_with_subtitles ( "video.mp4" , "output.srt" , "video_subtitled.mp4" )
Args:
video_file (str): Path to video file.
output_video_file (str, optional): Path to output video file. Defaults to video_file_subtitled.
output_subtitle_file (str, optional): Path to output SRT file. Defaults to "output.srt".
source_language (str, optional): Source language for translation. Defaults to en.
target_language (str, optional): Target language for translation. Defaults to None.
captioning_model_type (str, optional): Model type. Defaults to "base".
language_model_type (str, optional): Language model type. Defaults to "base".
model_dir (str, optional): Path to model directory. Defaults to None.
captioning_model_type
(音频到文本模型)的可用选项:
language_model_type
(语言翻译模型)的可用选项: