字幕

SubRip文件格式open in new window被描述为“可能是所有字幕格式中最基本的”。SubRip(SubRip Text)文件的扩展名为.srt,其中包含以空行分隔的格式化纯文本行组。字幕按顺序编号,从1开始。使用的时间码格式为小时:分钟:秒,毫秒,时间单位固定为两个零填充的数字,小数部分固定为三个零填充的数字(00:00:00,000)。小数分隔符为逗号,因为该程序是在法国编写的。

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

请从这里下载示例.srt文件open in new window

!pip install pysrt
from langchain.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'
Last Updated:
Contributors: 刘强