Giter VIP home page Giter VIP logo

speech-inquirer's Introduction

Make your web conversable

Introduction

Speech-inquirer.js lets you create conversational web apps. It wraps the Web Speech API and exposes a interface based on the famous command line library Inquirer.

Support

This library requieres Speech Synthesis API and Speech Recognition API. Check canisue to see the actual browser support for both.

Instalation

npm install speech-inquirer --save

Usage

var speechInquirer = require('speech-inquirer');
speechInquirer
  .prompt([
    /* Pass your questions in here */
  ])
  .then(answers => {
    // Use user feedback for... whatever!!
  });

[Chrome Deprecation] speechSynthesis.speak() without user activation is deprecated and will be removed in M71, around December 2018. See https://www.chromestatus.com/features/5687444770914304 for more details.

Docuemntation

Methods

inquirer.prompt(questions) -> promise

Start conversation (inquiry session)

Objects

Question

A question object is a hash containing question related values:

  • type: (String) Type of the prompt. Defaults: input - Possible values: input, confirm, list
  • name: (String) The name to use when storing the answer in the answers hash. If the name contains periods, it will define a path in the answers hash.
  • message: (String|Function) The question to print. If defined as a function, the first parameter will be the current inquirer session answers. Defaults to the value of name (followed by a colon).
  • default: (String|Number|Boolean|Array|Function) Default value(s) to use if nothing is entered, or a function that returns the default value(s). If defined as a function, the first parameter will be the current inquirer session answers.
  • choices: (Array|Function) Choices array or a function returning a choices array. If defined as a function, the first parameter will be the current inquirer session answers. Array values can be simple strings, or objects containing a name (to display in list), a value (to save in the answers hash) and a short (to display after selection) properties. The choices array can also contain a Separator.
  • validate (TODO): (Function) Receive the user input and answers hash. Should return true if the value is valid, and an error message (String) otherwise. If false is returned, a default error message is provided.
  • filter (TODO): (Function) Receive the user input and return the filtered value to be used inside the program. The value returned will be added to the Answers hash.
  • transformer (TODO): (Function) Receive the user input, answers hash and option flags, and return a transformed value to display to the user. The transformation only impacts what is shown while editing. It does not modify the answers hash.
  • when (TODO): (Function, Boolean) Receive the current user answers hash and should return true or false depending on whether or not this question should be asked. The value can also be a simple boolean.

Answers

A key/value hash containing the client answers in each prompt.

  • Key The name property of the question object
  • Value (Depends on the prompt)
    • confirm: (Boolean)
    • input : User input (filtered if filter is defined) (String)
    • list : Selected choice value (or name if no value specified) (String)

Example

var speechInquirer = require('speech-inquirer');
speechInquirer
  .prompt([{
	type: "list",
	name: "color",
	message: "Choose a color",
	choice: [
		"red",
		"green"
	]	
  }])
  .then(answers => {
    alert(answers.color);
  });

Plugins

Contributing

Documentation Add documentation for every API change. Feel free to send typo fixes and better docs!

Plugins

You can develop your own extensions for speech-inquirer.js. Just register a new question, a function that expects a question object and return and answer object.

speechInquirer.registerQuestion("input", handleInput)

License

MIT

speech-inquirer's People

Contributors

javidalpe avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

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.