npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@re-ai/subtitle_translation

v0.2.1

Published

AI字幕翻译工具包,支持SRT解析、OpenAI批量翻译、断点续传、双语输出等。

Downloads

23

Readme

@re-ai/subtitle_translation

AI字幕翻译工具包,支持SRT字幕解析、AI大模型批量翻译、断点续传、双语/单语输出、任务管理等。

功能特性

  • 支持SRT字幕文件解析,自动识别格式
  • 基于OpenAI等大模型API进行高质量字幕翻译
  • 支持批量翻译、断点续传、任务进度查询
  • 支持双语/单语字幕输出,边翻译边写入文件
  • 日志分级、彩色输出,便于调试
  • 任务可清理,输出文件自动删除

安装

npm install @re-ai/subtitle_translation

环境变量

  • OPENAI_API_KEYREAI_SUBTITLE_TRANS_OPENAI_API_KEY:OpenAI API Key
  • OPENAI_BASE_URLREAI_SUBTITLE_TRANS_OPENAI_BASE_URL:OpenAI API Base URL(如用代理)
  • REAI_SUBTITLE_TRANS_LOG_LEVEL:日志等级(debug/info/warn/error)
  • 其他可选:REAI_SUBTITLE_TRANS_OPENAI_MODELREAI_SUBTITLE_TRANS_OPENAI_TEMPERATUREREAI_SUBTITLE_TRANS_OPENAI_TOP_PREAI_SUBTITLE_TRANS_OPENAI_SYSTEM_PROMPT

快速使用

import { ReAISubtitleTranslator } from '@re-ai/subtitle_translation';

const translator = new ReAISubtitleTranslator({
  defaultBatchSize: 50,
  defaultBilingual: true,
  aiLLMConfig: {
    apiKey: process.env.OPENAI_API_KEY,
    model: 'gpt-3.5-turbo',
    systemPrompt: '',
    // ...其他参数
  }
});

// 创建翻译任务
const { taskId } = translator.createTranslateTask({
  filePath: './example.srt',
  to: 'zh',
  outputFile: './example.zh.srt',
  bilingual: true, // 输出双语
  batchSize: 30,   // 每批30条
  introduction: '' // 影片介绍
});

// 执行翻译
await translator.executeTranslateTask(taskId);

// 查询进度
const progress = translator.getTranslateTaskProgress(taskId);
console.log(progress);

// 清理任务(会自动删除输出文件)
translator.clearTask(taskId);

API 说明

Translator

  • constructor(options):初始化,支持默认批量大小、双语、AI参数
  • createTranslateTask({ filePath, to, outputFile?, bilingual?, batchSize? }):创建翻译任务
  • executeTranslateTask(taskId):执行翻译任务,自动分批、断点续传、边翻译边写入
  • getTranslateTaskProgress(taskId):查询任务进度
  • clearTask(taskId):清理任务及输出文件

AITranslator

  • 支持自定义大模型API参数,结构化输出

测试

npm run test

License

MIT