字幕
SubRip 文件格式在
Matroska
多媒体容器格式网站上被描述为“所有字幕格式中最基本的一种”。SubRip (SubRip Text)
文件以.srt
为扩展名命名,并包含多组格式化的纯文本行,各组之间以空行分隔。字幕按顺序编号,从 1 开始。使用的时间码格式为小时:分钟:秒,毫秒,时间单位固定为两位零填充数字,小数部分固定为三位零填充数字(00:00:00,000)。由于该程序在法国编写,所以小数分隔符使用逗号。
如何从字幕(.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'