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

subtitle-lib

v0.2.5

Published

subtitle-lib是Felo提供的字幕服务接入的SDK

Readme

目录

1. 背景

TODO: 待完善

2. 简介

TODO: 待完善

具有以下特性:

  • 字幕服务
  • 多语言翻译
  • 实时同步

3. 安装方式

目前,安装方式有以下几种:

3.1. 方式1:通过 npm 安装

通过 npm (或 yarn、pnpm 等包管理器)安装

npm install subtitle-lib

3.2. 方式3:通过<script>标签引入(TODO: 暂不支持)

您可直接从项目的 [发行地址][] 中下载以 .iife.js 作为缀的文件,然后使用如下代码引用 和 使用 subtitle-lib:

  1. 引用 subtitle-lib

    <script src="path/to/package/subtitle-lib.iife.js"></script>
  2. 使用全局的 subtitle-lib

    <script>
    // 使用全局的 subtitle-lib
    </script>
  3. 本地调试 subtitle-lib

    npm run dev
    // 访问 http://localhost:5173/demo/
    // 引入依赖
    import Subtitle, { SubtitleParams, IConnectStateType } from 'subtitle-lib';

4. 使用方法

// 加入字幕服务
const start = async () => {
    // log('获取token...');
    const { status, data } = await axios({"Server_URI"});
    if (status !== 200) {    
        // 获取token失败
        throw new Error('get token error ...');
    }
    //  获取token成功
    const { access_token, user_id, app_id } = data;
    // 创建字幕服务对象
    const subtitle = new Subtitle(app_id, 'WEB', true);
    
    // 配置字幕服务参数
    const opts: SubtitleParams = {
      token: 'access_token',
      bizId: '业务ID,每一个业务ID独立',
      userId: '用户唯一ID',
      lang: '输入的语言 「zh/ja/ko/en」',
    };
    // 获取生成字幕的音频媒体流
    const mediaStream: any = await navigator.mediaDevices.getUserMedia({audio: true});
    const audioMediaStreamTrack = mediaStream.getAudioTracks()[0];
    
    // 打开字幕服务
    // 第三个获取token的参数可以传,也可以不传,不传的情况就无法自动刷新token,当token过期时会抛异常
    await subtitle.joinAndStart(opts, audioMediaStreamTrack, async () => {
      const access_token = await request.get();
      return access_token;
    });
    
    // 打开字幕成功,设置接收字幕消息的回调
    subtitle.getTranslation(onMsg);
    
    // 如果需要监听字幕服务的链接状态,可以通过一下方法监听
    subtitle.getConnectState(onConnectStateChange);
};

// 关闭字幕服务
const stop = async () => {
    await subtitle.closeSubtitle();
}

// 接收字幕服务的回调信息(包含字幕信息)
const onMsg = (msg) => {
    // 打印字幕对象
    console.log(JSON.parse(msg.data.transcribeText));
};

// 与字幕服务器的链接状态,根据业务需求选用
const onConnectStateChange = (state : IConnectStateType) => {
    console.log('connectState : ', state);
    // 输出 connected/disconnect/reconnect/connecting
};

详情跳转至详细使用方法

5. API接口文档(TODO: 待完成)

详情跳转至[API接口文档][]