YouTube 文字记录
¥YouTube transcripts
本概述介绍如何将 YouTube 转录文本加载到 LangChain 文档中。
¥This covers how to load YouTube transcripts into LangChain documents.
设置
¥Setup
你需要安装 youtubei.js 来提取元数据:
¥You'll need to install the youtubei.js to extract metadata:
- npm
- Yarn
- pnpm
npm install @langchain/community @langchain/core youtubei.js
yarn add @langchain/community @langchain/core youtubei.js
pnpm add @langchain/community @langchain/core youtubei.js
用法
¥Usage
你需要在 url
中指定视频链接。你还可以在 ISO 639-1 和 addVideoInfo
标志中指定 language
。
¥You need to specify a link to the video in the url
. You can also specify language
in ISO 639-1 and addVideoInfo
flag.
import { YoutubeLoader } from "@langchain/community/document_loaders/web/youtube";
const loader = YoutubeLoader.createFromUrl("https://youtu.be/bZQun8Y4L2A", {
language: "en",
addVideoInfo: true,
});
const docs = await loader.load();
console.log(docs);
API Reference:
- YoutubeLoader from
@langchain/community/document_loaders/web/youtube