File size: 360 Bytes
45b9636
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
from langchain.docstore.document import Document


def segments_to_documents(segments, source_path):
    """Convert whisper segments to LangChain Document objects."""
    return [
        Document(
            page_content=s["text"],
            metadata={"start": s["start"], "end": s["end"], "source": source_path},
        )
        for s in segments
    ]