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

funasr-client

v0.1.2

Published

Really easy-to-use Typescript client for FunASR runtime server.

Downloads

71

Readme

FunASR-Client (TS/JS)

NPM GitHub

Really easy-to-use Typescript/JavaScript client for FunASR runtime service.

To deploy your own FunASR service, follow the FunASR runtime guide, or use the improved startup scripts. For other client implementations in different languages, see below.

Features

  • 🔤 Auto decoding of messages with real timestamps (FunASRMessageDecoded)
  • 🎙️ Real-time audio recognition from a microphone (MicASR)

Installation

NPM (Browser/Node.js)

npm install funasr-client
import { FunASRClient } from 'funasr-client';

// import this if you want real-time microphone ASR
import { MicASR } from 'funasr-client/mic';

ESM CDN (Browser)

Import the ESM module directly from a CDN:

<script type="importmap">
  {
    "imports": {
      "funasr-client": "https://esm.sh/funasr-client@latest",
      "funasr-client/mic": "https://esm.sh/funasr-client@latest/mic"
    }
  }
</script>
<script type="module">
  import { FunASRClient } from 'funasr-client';
  import { MicASR } from 'funasr-client/mic';
</script>

IIFE CDN (Browser)

All features are also available in the IIFE bundle dist/iife/index.global.js, which can be directly included in web pages. Tools are exposed in the global funasr object.

Import the IIFE module directly from a CDN:

<script src="https://cdn.jsdelivr.net/npm/funasr-client@latest/dist/iife/index.global.js"></script>
<script>
  // funasr object is available globally
  console.log(funasr.FunASRClient);
  console.log(funasr.MicASR);
</script>

Usage

FunASRClient

The only required option is the URL of the FunASR server.

const client = new FunASRClient({
  // (Required) URL of the FunASR server
  url: "ws://localhost:8000/ws",

  // Whether to decode the message before passing it to the `onMessage` callback.
  // Disable auto-decoding if you want to handle original message objects
  decode: true,

  // callback to handle incoming messages (FunASRMessageDecoded or FunASRMessage)
  onMessage: (msg) => {
    console.log("Received message:", msg);
  },

  // callback to handle state changes
  onStateChange: (state) => { 
    console.log("State changed:", state);
  },

  // the start timestamp (ms) for the audio recording
  startTime: Date.now(),

  // initial configuration for the first message
  config: {
    mode: "2pass",
    wav_name: "test.wav",
    wav_format: "pcm",
    chunk_size: [5, 10, 5],
    audio_fs: 16000,
    hotwords: { "hello": 20, "world": 30 },
    itn: true,
    svs_lang: "auto",
    svs_itn: true,
  }
});

// (async) Connect to the server and send the initial configuration.
client.connect();

// Set the start timestamp for the audio recording.
client.setStartTime(timestamp);

// Send a message to the server.
client.send(data);

// (async) Send the final message to the server, wait for the final result and then close the connection. An optional timeout can be provided.
client.close();

MicASR

The MicASR class provides a convenient way to perform real-time audio recognition from a microphone. It takes the same options as FunASRClient except for the decode option, which is always true for MicASR.

const mic_asr = new MicASR({
  url: 'ws://your-funasr-server-url'
});

// (async) Start the real-time ASR process by connecting to the FunASR server and starting the audio recorder.
mic_asr.start()

// (async) Stop the real-time ASR process by stopping the audio recorder and closing the FunASR client connection.
mic_asr.stop()

Different Client Implementations

References