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

nanospeech

v1.2.0

Published

Web speech api simplified

Downloads

22

Readme

nanospeech

Web speech api simplified

Usage

Text to speech

import { speak } from 'nanospeech'

speak('hello world')

Speech to text

import { recognition } from 'nanospeech'

recognition.start()

recognition.on('result', text => console.log(text))

Install

Include the following tags in your html

<script type="module" src="https://unpkg.com/nanospeech?module"></script>
<script nomodule src="https://unpkg.com/[email protected]/dist/nanospeech.umd.js"></script>

This will install the module version when the browser support modules and fallback to the umd version when it don't. You can still import or require this

import { speak } from 'nanospeech'

// or

var speak = require('nanospeech').speak

API

let speech = speak(text, [opts])

The speak function speak a text passed as the first argument. Optionally the following options can be passed as an object on the second argument:

  • lang(DOMString): A BCP47 format string (eg. en-US) to set the language to be spoken. Notice that the selected language must be supported by the availaible voices, otherwise, default voice and language will be used.
  • rate(float): The speed of the utterance to be spoken, can be a value from 0.1 to 10, defaults to 1.
  • pitch(float): The pitch of the utterance to be spoken, can be a value from 0 to 2, defaults to 1.
  • volume(float): The volume of the utterance to be spoken, can be a value from 0 to 1, defaults to 0.5.

The speech object returned is an Event Emitter like object. It has two single methods on and emit (There is no off method because there is actually no event going on, so no need to remove listeners)

speech.on(event, handler)

event is a string with the name of the event to listen to. handler is a function which always get a SpeechSynthesisEvent as its argument. Availaible events are:

  • start: Emitted when a speech starts.
  • boundary: Emitted when a word or sentence boundary is reched during a speech.
  • end: Emitted when a speech finish being spoken.

speech.emit(event)

event is a string with the name of the event to be emited. Also, every string has a function version, making speech.emit('pause') equivalent to speech.pause()

  • cancel: Emit this event to cancel all qeued speechs.
  • pause: Emit this event to pause an ongoing speak. If there is no speaking taking place, it will do nothing.
  • resume: Emit this event to resume an ongoing speak. If there is no paused speaking, it will do nothing.

recognition.on(event, handler)

event is a string with the name of the event to listen to. handler is a function which always get a SpeechRecognitionEvent as its argument, with the exception of the result event which gets the text recognized as a string for the argument. Availaible events are:

  • nomatch: Fired when the speech recognition service returns a final result with no significant recognition.
  • audiostart: Fired when the user agent has started to capture audio.
  • audioend: Fired when the user agent has finished capturing audio.
  • soudnstart: Fired when any sound — recognisable speech or not — has been detected.
  • soundend: Fired when any sound — recognisable speech or not — has stopped being detected.
  • speechstart: Fired when sound that is recognised by the speech recognition service as speech has been detected.
  • speechend: Fired when speech recognised by the speech recognition service has stopped being detected.
  • end: Fired when the speech recognition service has disconnected.
  • result: Fired when the speech recognition service returns a result.

recognition.emit(event)

event is a string with the name of the event to be emited. Also, every string has a function version, making speech.emit('start') equivalent to speech.start()

  • start: Fired when the speech recognition service has begun listening to incoming audio.
  • stop: Emit this event to stops the speech recognition service from listening to incoming audio, and attempts to return a SpeechRecognitionResult using the audio captured so far.
  • abort: Stops the speech recognition service from listening to incoming audio.

LICENSE

MIT