[docs]def__init__(self,file_path:Union[str,Path]):"""Initialize with a file path."""try:importpysrt# noqa:F401exceptImportError:raiseImportError("package `pysrt` not found, please install it with `pip install pysrt`")self.file_path=str(file_path)
[docs]defload(self)->List[Document]:"""Load using pysrt file."""importpysrtparsed_info=pysrt.open(self.file_path)text=" ".join([t.textfortinparsed_info])metadata={"source":self.file_path}return[Document(page_content=text,metadata=metadata)]