字幕
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'