兼容性仅在 Node.js 上可用。
本文介绍如何使用 Open AI Whisper API 从音频文件加载文档对象。

设置

要运行此加载器,您需要在 Open AI 上创建帐户,并从 https://platform.openai.com/account 页面获取身份验证密钥。

用法

配置身份验证密钥后,您可以使用加载器创建转录,然后将其转换为 Document。
import { OpenAIWhisperAudio } from "@langchain/community/document_loaders/fs/openai_whisper_audio";

const filePath = "./src/document_loaders/example_data/test.mp3";

const loader = new OpenAIWhisperAudio(filePath, {
  transcriptionCreateParams: {
    language: "en",
  },
});

const docs = await loader.load();

console.log(docs);

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.