Giter Site home page Giter Site logo

praise's Introduction

Praise ๐Ÿ™Œ๐Ÿฟ

Praise is a client-side helper that... well, helps do things using your voice in a browser environment. This project uses the Web Speech API, which is still an experimental browser technology and is only currently supported in Google Chrome. Use with discretion. At some point, as the Web Speech specification moves closer to finalization and inclusion, Praise aims to keep up with the changes.

Disclaimer: the current SpeechRecognition API (part of the Web Speech API) supported in Chrome requires an internet connection and connects to Google's Web Speech service under the hood.

Motivation

I created this project on a Saturday afternoon in just a few hours in order to demonstrate the welcoming, efficient nature of JavaScript for my talk at JSConf EU.

Getting Started

To get up and running with Praise, it's pretty standard: simply install it with yarn.

  • yarn add praise

... done.

Of course, you may also use npm if you are so inclined (npm i praise --save).

Basic Usage

Praise exports a createPraise function that returns a Praise instance that can be started and stopped at your leisure, in a browser that can and wants to listen. Here's how a simple project can be set up.

Be sure to include the compiled version of this file in a HTML file, using Parcel, Webpack, Poi or a similar bundler.

import { createPraise } from "praise";

const whenISay = {
  ooga: () => alert("booga"),
  "am i pretty": () => alert("the prettiest!")
};

const myPraiseListener = createPraise(whenISay); // for customizing, use createPrase(whenISay, myOptions)
myPraiseListener.start();

Starting this app in a browser, and then saying either "ooga" or "am I pretty" will execute their respective functions. Pretty cool, eh? This allows you to do literally anything that you can do programatically with your voice.

Options

createPraise takes an optional second argument specifying the following configuration options for more fine-grained control. Here are the defaults, when everything is left blank:

{
  /** Indicates whether Praise should keep listening or stop listening after the first match. */
  keepListening: true;

  /** Indicates whether Praise should return results _as you speak_ or after you stop speaking. */
  onlyWhenIStop: false;

  /** A minimum threshold of confidence for matches. A higher number hear means more accurate, but fewer matches. */
  confidence: 0.8;

  /** A callback executed on successful execution of a phrase callback that gets the result of the callback for a phrase. */
  onSuccess: () => undefined;
}

Usage with React

Praise also has React bindings! react-praise can do some nifty things in a React app, like change presentation slides or other things. Feel free to submit Pull Requests that demonstrate your cool idea/use case!

Contributing

Open issues and make PRs as you wish.

praise's People

Contributors

dependabot[bot] avatar tejasq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

osmanzeki

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.