Download Latest Version annyang v3.0.0 source code.tar.gz (93.2 kB)
Email in envelope

Get an email when there's a new version of annyang!

Home / v3.0.0
Name Modified Size InfoDownloads / Week
Parent folder
annyang v3.0.0 source code.tar.gz 2026-03-11 93.2 kB
annyang v3.0.0 source code.zip 2026-03-11 103.7 kB
README.md 2026-03-11 2.9 kB
Totals: 3 Items   199.8 kB 0

annyang v3 — Rewritten in TypeScript. Modern modules. Zero dependencies. 2 KB.

annyang v3 is a ground-up rewrite. The library is now written in TypeScript, ships its own type definitions, and supports every module format — ESM, CommonJS, and IIFE script tags. It's still tiny (2 KB), still has zero dependencies, and now works safely in browsers that don't support speech recognition.

:::js
import annyang from 'annyang';

annyang.addCommands({
  'search for *term': (term) => { console.log(`Searching for ${term}`); },
});

if (annyang.isSpeechRecognitionSupported()) {
  annyang.start();
} else {
  // trigger() works even without speech recognition —
  // great for testing, automation, or fallback UIs in non-supporting browsers
  annyang.trigger('search for cat videos');
}

Named imports work too:

:::js
import { addCommands, start, trigger, isSpeechRecognitionSupported } from 'annyang';

New Features / Breaking Changes

  • TypeScript types included — Full type definitions ship with the package.
  • addCallback enforces correct callback signatures per event type.
  • ESM/CJS/IIFE module support — Works with import, require(), and <script> tags.
  • getState() method — Returns 'idle', 'listening', or 'paused'.
  • state property (on default export) — Getter that returns the current state.
  • addCallback returns an unsubscribe function: js const unsub = annyang.addCallback('start', myFunc); unsub(); // removes myFunc from 'start' callbacks
  • trigger() works independently of speech recognitiontrigger() can now be used regardless of whether annyang is listening, paused, aborted, or even in browsers that don't support speech recognition.
  • Safe to use in unsupported browsers — Methods like start(), addCommands(), and setLanguage() no longer throw when SpeechRecognition is unavailable.
  • if (annyang) no longer detects browser support — The annyang object is always defined in v3. Use isSpeechRecognitionSupported() instead: ```js // v2 if (annyang) { annyang.start(); }

// v3 if (annyang.isSpeechRecognitionSupported()) { annyang.start(); } ```

  • init() deprecated — annyang has been initializing automatically since v1.1.0. Calling init() now logs a deprecation warning. Remove any calls to init().
  • String-based command callbacks removed — Passing function names as strings (e.g., {'hello': 'sayHello'}) is no longer supported. Pass functions directly: {'hello': sayHello}.
  • Duplicate command phrases now overwrite — In v2, adding a command with the same phrase would register both. In v3, the new callback replaces the old one.

Internal

  • Source rewritten in TypeScript with strict mode
  • Bundler switched from Rollup to tsup
  • Tests migrated to Vitest
Source: README.md, updated 2026-03-11