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

web-voice-command

v1.0.15

Published

Making voice command on the web better

Downloads

8

Readme

web-voice-command

Install

npm i web-voice-command

Usage

Compatibility:

Currently only works on chrome. Other browsers do not have support for the Web Speech API as of June 2020.

Options:

  • Use setOptions to set the options you need.
  • persistentListening: If true listening will be continuous, if false listening will only last four secounds. * When using the startStop method persistentListening option doesn't come into effect. StartStop method will continuously listen until stoped
  • listenOnLoad: If ture listening will start when the page loads. If persistentListening is false listening will only last four seconds.

Default options

  • persistentListening: false
  • listenOnLoad: false
  • language: 'en-US'

Methods:

  • setOptions: Used to set options
 webVoiceCommand.setOptions({
  persistentListening: true,
  listenOnLoad: true,
  language: 'ro-RO' //set language to ro-RO Romanian Romania
})

setting language use BCP 47 Language Codes BCP 47 Language Codes:

ar-SA Arabic Saudi Arabia
cs-CZ Czech Czech Republic
da-DK Danish Denmark
de-DE German Germany
el-GR Modern Greek Greece
en-AU English Australia
en-GB English United Kingdom
en-IE English Ireland
en-US English United States
en-ZA English South Africa
es-ES Spanish Spain
es-MX Spanish Mexico
fi-FI Finnish Finland
fr-CA French Canada
fr-FR French France
he-IL Hebrew Israel
hi-IN Hindi India
hu-HU Hungarian Hungary
id-ID Indonesian Indonesia
it-IT Italian Italy
ja-JP Japanese Japan
ko-KR Korean Republic of Korea
nl-BE Dutch Belgium
nl-NL Dutch Netherlands
no-NO Norwegian Norway
pl-PL Polish Poland
pt-BR Portuguese Brazil
pt-PT Portuguese Portugal
ro-RO Romanian Romania
ru-RU Russian Russian Federation
sk-SK Slovak Slovakia
sv-SE Swedish Sweden
th-TH Thai Thailand
tr-TR Turkish Turkey
zh-CN Chinese China
zh-HK Chinese Hong Kong
zh-TW Chinese Taiwan

  • results: Returns all voice inputs in arrays that are separated by pauses in voice inputs.
 webVoiceCommand.results(function(result){
  console.log(result)
})

console with voice input "hello world".

(2) ["hello", "world"]
  • startStop: Use with DOM events, like button clicks, to start and stop listening. First parameter is either 1 or 2. 1 being one DOM element and 2 being two separate DOM elements, one element sending the value “start” and the other sending the value “stop”.
function handleClick(event) {
  webVoiceCommand.startStop(2, event.target.value)
}
<button value='start' onClick={handleClick}>Start</button>
<button value='stop' onClick={handleClick}>Stop</button>
  • wordList: *Requires the persistentListening option to be set to true.
    • wordList is used to return only word you listed.
      • Without actionsWords: returns an array of words as many time they are vocilized. But will only return words that are listed.
      • With actionWords: returns only a single word vocilized after the actionWord and that is listed in the options array as a word.
    • Takes three parameters:
    1. First an array of objects with or without actionWords.
    Without actionWords
    const words = [
      {
        word: {
        name: 'red',
        alternateWord: []
        }
      },
      { 
        word: {
          name: 'blue',
          alternateWord: []
        }
      },
      {
        word: {
          name: 'yellow',
          alternateWord: []
        }
      }
    ]
    With actionWords
    const words = [
      {
        actionWord: {
          name: 'pick',
          options: [
            {
              word: 'blue',
              alternateWord: []
            }, 
            {
              word: 'red',
              alternateWord: []
            }, 
            {
              word: 'yellow',
              alternateWord: []
          }]
        }
      },
      {
        actionWord: {
          name: 'select',
          options: [
            {
              word: 'home',
              alternateWord: []
            },
            {
              word: 'about',
              alternateWord: []
            },
            {
              word: 'contact',
              alternateWord: []
            }
          ]
        }
      }
    ]
    1. Second a boolean if actionWords are being used.
    const withActions = false
    1. Third a callback that returns an array of matched words if you are not using actionWords or a single word if you are using actionWords.
    webVoiceCommand.wordList(words, withActions, function(result) {
    console.log(result)
    })
    console without actionWords. Voice input "red blue yellow".
    (3) ["red", "blue", "yellow"]
    console with actionWords. Voice input "select home".
    home

Author

Matthew Sandoval