# @deepgram/captions 中文文档

规范地址：https://npmcn.com/package/%40deepgram/captions/

版本：1\.2\.0
npm 元数据更新时间：2026-09-11T09:54:14.467Z
中文译文更新时间：2026-11-11T19:59:24.545Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40deepgram/captions
原文对照：https://npmcn.com/package/%40deepgram/captions/?lang=original
项目主页：https://github.com/deepgram/deepgram-node-captions
源码仓库：https://github.com/deepgram/deepgram-node-captions

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：86.1 kB，76 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=18\.0\.0
- 运行依赖：1 个
- 首次发布：2023-10-28T09:51:24.959Z
- 最新版本发布：2023-11-07T08:30:20.464Z
- 近 30 天下载量：2653553（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：4（近 12 个月 0 个）

## 中文简介

节点执行Deepgram的WebVTT和SRT格式化. 鉴于一个抄写,这个包可以返回一个有效的字符串来存储为WebVTT或SRT标题文件.

## 安装

```sh
npm install @deepgram/captions
```

也可以使用：`pnpm add @deepgram/captions`、`yarn add @deepgram/captions`、`bun add @deepgram/captions`

## README

# 深方块说明

这个软件包是Deepgram的WebVTT和SRT格式化的JavaScript执行. 鉴于一个抄写,这个包可以返回一个有效的字符串来存储为WebVTT或SRT标题文件.

> 使用任何复制格式.

## 安装

```bash
npm install @deepgram/captions
# - or -
# yarn add @deepgram/captions
```

## 来自 Deepgram 的 WebVTT 译名

```ts
import { webvtt } from "@deepgram/captions";

const result = webvtt(deepgram_transcription_result);
```

## 来自 Deepgram 译名的 SRT

```ts
import { srt } from "@deepgram/captions";

const result = srt(deepgram_transcription_result);
```

## 转换器

此软件包已经构建, 可以转换任何文本格式 。 你只需要提供 `converter` 分类为格式化者提供正确的数据.

### 示例转换器

一个通用的转换器会像这样:

```ts
import { chunkArray, WordBase, IConverter } from "@deepgram/captions";

export class GenericConverter implements IConverter {
  constructor(public transcriptionData: any) {}

  getLines(lineLength: number = 8): WordBase[][] {
    const results = this.transcriptionData;
    let content: WordBase[][] = [];

    results.paragraphs.forEach((paragraph) => {
      if (paragraph.words.length > lineLength) {
        content.push(...chunkArray(paragraph.words, lineLength));
      } else {
        content.push(paragraph.words);
      }
    });

    return content;
  }
}
```

它要求 `getLines` 返回以下数据结构:

```ts
// const transcriptionData: WordBase[][] = [
const transcriptionData = [
  [
    {
      word: string;
      start: number;
      end: number;
      punctuated_word: string; // optional
    }
  ]
]
```

使用您的转换器会看起来像这样:

```ts
import { srt } from "@deepgram/captions";

const result = srt(new GenericConverter(transcription_result));
```

### 包含转换器

#### 大会

```ts
import { webvtt, AssemblyAiConverter } from "@deepgram/captions";

const result = webvtt(new AssemblyAiConverter(assembly_result));
```

## 输出 WebVTT

转录时 [https://dpgr.am/spacewalk.wav (英语)](https://dpgr.am/spacewalk.wav),并通过我们的库运行,这是WebVTT的输出.

```ts
import { webvtt } from "@deepgram/captions";

const result = webvtt(deepgram_transcription_result);

console.log(result);
```

结果是:

```text
WEBVTT

NOTE
Transcription provided by Deepgram
Request Id: 686278aa-d315-4aeb-b2a9-713615544366
Created: 2023-10-27T15:35:56.637Z
Duration: 25.933313
Channels: 1

00:00:00.080 --> 00:00:03.220
Yeah. As as much as, it's worth celebrating,

00:00:04.400 --> 00:00:05.779
the first, spacewalk,

00:00:06.319 --> 00:00:07.859
with an all female team,

00:00:08.475 --> 00:00:10.715
I think many of us are looking forward

00:00:10.715 --> 00:00:13.215
to it just being normal and

00:00:13.835 --> 00:00:16.480
I think if it signifies anything, It is

00:00:16.779 --> 00:00:18.700
to honor the the women who came before

00:00:18.700 --> 00:00:21.680
us who, were skilled and qualified,

00:00:22.300 --> 00:00:24.779
and didn't get the same opportunities that we

00:00:24.779 --> 00:00:25.439
have today.
```

## 输出 SRT

转录时 [https://dpgr.am/spacewalk.wav (英语)](https://dpgr.am/spacewalk.wav),并运行它 在我们的库, 这是SRT输出.

```ts
import { srt } from "@deepgram/captions";

const result = srt(deepgram_transcription_result);

console.log(result);
```

结果是:

```text
1
00:00:00,080 --> 00:00:03,220
Yeah. As as much as, it's worth celebrating,

2
00:00:04,400 --> 00:00:07,859
the first, spacewalk, with an all female team,

3
00:00:08,475 --> 00:00:10,715
I think many of us are looking forward

4
00:00:10,715 --> 00:00:14,235
to it just being normal and I think

5
00:00:14,235 --> 00:00:17,340
if it signifies anything, It is to honor

6
00:00:17,340 --> 00:00:19,820
the the women who came before us who,

7
00:00:20,140 --> 00:00:23,580
were skilled and qualified, and didn't get the

8
00:00:23,580 --> 00:00:25,439
same opportunities that we have today.
```

## 文档

你可以更多地了解Deepgram API [开发者. diepgram.com](https://developers.deepgram.com/docs)。 。 。 .

## 发展与促进

有兴趣捐款吗? 我们拉请求!

确保我们的社区对所有人安全,确保审查和同意我们 [行为守则](https://npmcn.com/package/%40deepgram/captions/.github/CODE_OF_CONDUCT.md)。然后见 [捐款](https://npmcn.com/package/%40deepgram/captions/.github/CONTRIBUTING.md) 更多信息指南.

## 获取帮助

我们很想听到你的消息 所以如果你有问题、评论或发现窃听器 项目,让我们知道! 你们也可以:

-   [在此仓库中打开一个问题](https://github.com/deepgram/%5Breponame%5D/issues/new)
-   [加入Deepgram Github讨论社区](https://github.com/orgs/deepgram/discussions)
-   [加入 Deepgram Discord 社区](https://discord.gg/xWRaCDBtW4)

## 常见问题

### @deepgram/captions 是什么？

节点执行Deepgram的WebVTT和SRT格式化\. 鉴于一个抄写,这个包可以返回一个有效的字符串来存储为WebVTT或SRT标题文件\.

### 如何安装 @deepgram/captions？

在项目目录运行 npm install @deepgram/captions，或使用 pnpm add / yarn add / bun add。

### @deepgram/captions 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @deepgram/captions 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @deepgram/captions 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=18\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @deepgram/captions 可以商用吗？

@deepgram/captions 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @deepgram/captions 的下载量有多少？

根据 npm 官方下载统计，@deepgram/captions 在 2026/10/12 – 2026/11/10 这 30 天内被下载 2,653,553 次，日均约 88,452 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @deepgram/captions 还在维护吗？

最新版本 1\.2\.0 发布于 2023/11/07（3 年前）；至今共发布 4 个版本，其中过去 12 个月发布了 0 个；首次发布于 2023/10/28。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

