Skip to content

machenme/video2srt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

获取视频(音频)的双语字幕文件 get video(audio) srt file

开发环境:
Pyhton 3.12
Pytorch 2.2
requirement.txt

输出结果 srt文件 output srt file

1
00:00:02,540 --> 00:00:07,560
Defining functions, one of the most important things you will do in this class.
定义函数,这是您在这个类中要做的最重要的事情之一。

2
00:00:09,000 --> 00:00:16,020
Before I talk about the details of defining functions, let's just take a moment to appreciate this moment.
在我讨论定义函数的细节之前,让我们花点时间来欣赏一下这一时刻。

3
00:00:16,760 --> 00:00:24,180
So, I told you on the first day that this course is all about abstraction, and today we're learning tools for abstraction.
所以,我在第一天告诉你,这门课程都是关于抽象的,今天我们正在学习抽象工具。

使用方法 usage

使用mp3文件会跳过ffmpeg转换阶段
use mp3 file will ignore ffmpeg trnaform part

python getVideoSrt.py xxx.mp4 默认生成en-zh双语字幕
python getVideoSrt.py xxx.mp4 en zh zh 生成单中文字幕
python getVideoSrt.py xxx.mp4 medium fra en fra-en

usage: 1.py [-h] filename [model_name] [from_lang] [to_lang] [srt_type]

获取视频字幕.

positional arguments:
  filename    文件路径
  model_name  whisper模型选择 (default: base.en), whisper model select 参考信息 https://github.com/openai/whisper
  from_lang   视频原始语言 (default: en)
  to_lang     双语字幕第二语言 (default: zh)
  srt_type    字幕类型,单中?单英?中英?英中? (default: en-zh) Subtitle type, single Chinese? single English? zh-en? en-zh?

options:
  -h, --help  show this help message and exit

你可以 更改下面两个python变量 控制每一句字幕的提前出现时间和延后消失时间,默认延迟消失0.2秒
You can change the following two python variables to control the early appearance time and delayed disappearance time of each subtitle. The default delay is 0.2 seconds.

    start_early_time = 0
    end_late_time = 0.2

百度翻译支持的语言 Baidu translate support language

名称代码名称代码名称代码
自动检测auto中文zh英语en
粤语yue文言文wyw日语jp
韩语kor法语fra西班牙语spa
泰语th阿拉伯语ara俄语ru
葡萄牙语pt德语de意大利语it
希腊语el荷兰语nl波兰语pl
保加利亚语bul爱沙尼亚语est丹麦语dan
芬兰语fin捷克语cs罗马尼亚语rom
斯洛文尼亚语slo瑞典语swe匈牙利语hu
繁体中文cht越南语vie  

About

获取视频(音频)字幕 Get video(audio) srt

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages