副标题
The SubRip 文件格式 在
Matroska多媒体容器格式网站上被描述为“所有字幕格式中最基本的一种”。SubRip (SubRip Text)文件以扩展名为.srt的方式命名,并包含分隔为空行的多组格式化文本行。字幕按顺序编号,从 1 开始。所使用的时间代码格式为小时:分钟:秒,毫秒,时间单位固定为两位零填充数字,小数部分固定为三位零填充数字(00:00:00,000)。由于程序是在法国编写,因此使用的分隔符是逗号。
如何从字幕(.srt)文件加载数据
请从这里下载示例.srt文件。
%pip install --upgrade --quiet pysrt
from langchain_community.document_loaders import SRTLoader
API 参考:SRTLoader
loader = SRTLoader(
"example_data/Star_Wars_The_Clone_Wars_S06E07_Crisis_at_the_Heart.srt"
)
docs = loader.load()
docs[0].page_content[:100]
'<i>Corruption discovered\nat the core of the Banking Clan!</i> <i>Reunited, Rush Clovis\nand Senator A'