> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Sonix 音频集成

> 使用 LangChain JavaScript 与 Sonix 音频文档加载器集成。

<Tip>
  **兼容性**

  仅在 Node.js 上可用。
</Tip>

本文介绍如何使用 [Sonix](https://sonix.ai/) API 从音频文件加载文档对象。

## 设置

要运行此加载器，您需要在 [https://sonix.ai/](https://sonix.ai/) 上创建一个账户，并从 [https://my.sonix.ai/api](https://my.sonix.ai/api) 页面获取认证密钥。

您还需要安装 `sonix-speech-recognition` 库：

```bash npm theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
npm install @langchain/community @langchain/core sonix-speech-recognition
```

## 用法

配置好认证密钥后，您可以使用加载器创建转录，然后将其转换为文档。
在 `request` 参数中，您可以通过设置 `audioFilePath` 指定本地文件，或使用 `audioUrl` 指定远程文件。
您还需要指定音频语言。请参阅 [Sonix 支持的语言列表](https://sonix.ai/docs/api#languages)。

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { SonixAudioTranscriptionLoader } from "@langchain/community/document_loaders/web/sonix_audio";

const loader = new SonixAudioTranscriptionLoader({
  sonixAuthKey: "SONIX_AUTH_KEY",
  request: {
    audioFilePath: "LOCAL_AUDIO_FILE_PATH",
    fileName: "FILE_NAME",
    language: "en",
  },
});

const docs = await loader.load();

console.log(docs);
```

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档连接](/use-these-docs)到 Claude、VSCode 等，通过 MCP 获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/document_loaders/web_loaders/sonix_audio_transcription.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
