Skip to main content
Open In ColabOpen on GitHub

副标题

The SubRip file formatMatroska 多媒体容器格式网站上被描述为“或许是最基本的所有字幕格式”。 SubRip (SubRip Text) 文件的扩展名为 .srt,并且包含格式化的纯文本行,这些行由空行分隔。字幕按顺序编号,从 1 开始。使用的时码格式是 hours:minutes:seconds,milliseconds,其中时间单位固定为两位零填充数字,小数部分固定为三位零填充数字 (00:00:00,000)。由于该程序是在法国编写的,因此使用逗号作为小数分隔符。

如何从字幕 (.srt) 文件加载数据

请在此处下载 示例 .srt 文件

%pip install --upgrade --quiet  pysrt
from langchain_community.document_loaders import SRTLoader
API Reference: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'