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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aurally/speech-control

v1.1.2

Published

A class to handle microphone permissions, start and observe speech input

Downloads

26

Readme

Speech Control

A class to handle microphone permissions, start and observe speech input. It also adds a simple notification which lets the user disable

Usage

Start the recognition

Call the start function and the notification will appear which tells the user the app is listening. It will return an observable which calls the next handler on every user input with the corresponding SpeechRecognitionEvent. It will fail if the speech recognition fails or the user disables it with the corresponding events. It will finish after calling .stop().

  const speechControl = new SpeechControl();
  speechControl
    .start()
    .subscribe(SpeechRecognitionEvent => {}, SpeechControlErrors | SpeechRecognitionError => {}, Event => {})

Listening for a specific word

You can also just listen for specific keywords/phrases. In this case the subscribe handler just gets called when user said this word.

  const speechControl = new SpeechControl();
  speechControlContinue = speechControl.on('continue').subscribe(SpeechRecognitionEvent => {}, SpeechControlErrors | SpeechRecognitionError => {}, Event => {});

Permission Handling

There are two ways to handle permissions. You can ask the user directly or wait for him to allow the microphone permission.

  • askForPermission(): Observable<any>: triggers the microphone permission prompt and completes when the user allows, errors when denied
  • whenPermissionGranted(): Observable<any>: completes when the microphone permission is granted, errors when denied

Other

  • setNotification({container?: HtmlElement, text?: string, disableText?:string}): void: lets you customize the notification
  • isEnabled(): boolean: checks if SpeechRecognition is supported or user disabled the speech recognition
  • stop(): void: stops the recognition and removes the notification

Options

const speechControl = new SpeechControl(options?);
  • recLanguage: set the recording language, default is the HTML document language or users browser language