Skip to main content

Sonix 音频

¥Sonix Audio

Compatibility

仅在 Node.js 上可用。

¥Only available on Node.js.

本概述如何使用 Sonix API 从音频文件加载文档对象。

¥This covers how to load document objects from an audio file using the Sonix API.

设置

¥Setup

要运行此加载器,你需要在 https://sonix.ai/ 上创建一个账户,并从 https://my.sonix.ai/api 页面获取授权密钥。

¥To run this loader you will need to create an account on the https://sonix.ai/ and obtain an auth key from the https://my.sonix.ai/api page.

你还需要安装 sonix-speech-recognition 库:

¥You'll also need to install the sonix-speech-recognition library:

npm install @langchain/community @langchain/core sonix-speech-recognition

用法

¥Usage

配置好授权密钥后,你可以使用加载器创建转录,然后将其转换为文档。在 request 参数中,你可以通过设置 audioFilePath 指定本地文件,也可以使用 audioUrl 指定远程文件。你还需要指定音频语言。请参阅 此处 支持的语言列表。

¥Once auth key is configured, you can use the loader to create transcriptions and then convert them into a Document. In the request parameter, you can either specify a local file by setting audioFilePath or a remote file using audioUrl. You will also need to specify the audio language. See the list of supported languages here.

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);

API Reference: