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

glyphix-utils

v2.0.0

Published

Glyphix JsApp 常用工具模块。

Readme

glyphix-utils

Glyphix JsApp 常用工具模块。

API 服务开通

腾讯云服务密钥创建 腾讯 TTS API 开通 腾讯一句话识别

安装

yarn add glyphix-utils -S

ASR — 语音识别

将音频文件转为文字文本。

Google Cloud Speech-to-Text

import { GoogleRecognition } from 'glyphix-utils';

const result = await new GoogleRecognition().createRecognition(
  '/path/to/audio.mp3',
  {
    secretKey: '<Google API Key>',
    config: {
      encoding: 'MP3',
      sampleRateHertz: 16000,
      languageCode: 'cmn-Hans-CN',
    },
  },
);

| 状态码 | 常量 | 说明 | |--------|------|------| | 0 | AsrCode.SUCCESS | 识别成功 | | 1 | AsrCode.EMPTY_RESULT | 无识别结果 | | 1002 | AsrCode.REQUEST_FAILED | 网络请求失败 | | 1003 | AsrCode.API_ERROR | API 返回错误 | | 9999 | AsrCode.UNKNOWN_ERROR | 未知错误 |

语言代码:cmn-Hans-CN(普通话)en-US(英语)yue-Hant-HK(粤语)

腾讯云语音识别

import { TencentRecognition } from 'glyphix-utils';

const result = await new TencentRecognition().createRecognition(
  '/path/to/audio.pcm',
  {
    secretId: '<SecretId>',
    secretKey: '<SecretKey>',
    config: {
      voiceFormat: 'pcm',
      serviceType: '16k_zh',  // 16k_zh | 8k_zh | 16k_en
    },
  },
);

支持的音频格式:wav pcm ogg-opus speex silk mp3 m4a aac amr

TTS — 语音合成

将文字合成为音频文件。

Google Cloud Text-to-Speech

import { googleTTS } from 'glyphix-utils';

await googleTTS({
  secretKey: '<Google API Key>',
  text: 'hello world',
  language: 'en-US',
  saveFilename: '/path/to/output.mp3',
  format: 'MP3',
});

腾讯云语音合成

import { tencentTTS } from 'glyphix-utils';

await tencentTTS({
  secretId: '<SecretId>',
  secretKey: '<SecretKey>',
  text: '你好世界',
  saveFilename: 'internal://files/audio.mp3',
  // 以下可选
  config: {
    voiceType: 0,        // 音色 ID
    codec: 'mp3',        // wav | mp3 | pcm
    speed: 0,            // 语速 [-2, 2]
    volume: 0,           // 音量 [0, 10]
    sampleRate: 16000,   // 8000 | 16000
  },
});

文本长度限制:中文最大 150 字,英文最大 500 字母,超出直接抛错。

EventEmitter

事件总线,用于模块间数据通信。

在页面中监听事件,建议在 OnHide 中取消监听,避免页面隐藏后回调异常。

import { EventEmitter } from 'glyphix-utils';

const emitter = new EventEmitter();

// on 返回 id,可用于 off 取消监听
const id = emitter.on('test', (msg) => console.debug(msg));

// 仅触发一次
emitter.once('test-once', (msg) => console.debug('once', msg));

// 取消指定监听
emitter.off('test', id);

// 取消某类型所有监听
emitter.offAll('test');

节流与防抖

import { throttled, debounce } from 'glyphix-utils';

// 节流:delay ms 内只执行一次
const fn = throttled((args) => console.debug(args), 1000);

// 防抖:wait ms 后执行,重复触发则重新计时
const fn2 = debounce((args) => console.debug(args), 5000);