Skip to main content
SubRip 文件格式Matroska 多媒体容器格式网站上被描述为”也许是所有字幕格式中最基础的一种”。SubRip(SubRip Text) 文件以 .srt 为扩展名,包含由空行分隔成组的纯文本格式行。字幕按顺序编号,从 1 开始。使用的时间码格式为 时:分:秒,毫秒,时间单位均以两位零填充数字表示,小数位以三位零填充数字表示(00:00:00,000)。分隔符为逗号,因为该程序是在法国编写的。
如何从字幕(.srt)文件加载数据 请从此处下载示例 .srt 文件
pip install -qU  pysrt
from langchain_community.document_loaders import 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'