Giter VIP home page Giter VIP logo

voicebox's Introduction

VoiceBox

example

Download

How

Press alt+s to trigger the voicebox window

What can you do?

VoiceBox currently has a very limited set of sentences it understands. If you want to contribute to this, please look at the adding responders section.

Hello
What time is it?
My name is Thomas
What's my name?
Tell me about [any topic]
What is a guitar
What's the weather like in Dublin

Adding better voices

You can change the voice in the OS X speech and dictation settings. In the system voice dropdown you can select 'custom' which will allow you to download more voices. I use 'Samantha' which is the same voice used by siri on the iPhone.

voices

Dev Setup

VoiceBox is built on top of electron.

npm install
electron .

Now press alt+s

Adding responders

Create a new javascript file for your responder in the /responders directory. You can then use the voiceBox.addResponder method to define your responder.

The addResponder method takes two parameters:

  • regex ( Regex ): The users input will be matched against this to determine if it should respond
  • response ( Function ) : If the regex matches the input the response function will be called

The voiceBox.respond(message) method is then used inside the response function to output a response.

NB: The response function is only called if it is the last responder to match the input

voiceBox.addResponder(/Hi|Hello|Hey/i, function(){
  voiceBox.respond("Hello")
})

Responders with API requests

voiceBox.request can be used to make external API requests.

NB: This uses the request module

voiceBox.addResponder(/What's the weather like in (.*)/i, function(){
  voiceBox.request('http://api.openweathermap.org/data/2.5/weather?q='+RegExp.$1, function (error, response, body) {
    if (!error && response.statusCode == 200) {
      voiceBox.respond(JSON.parse(body).weather[0].description)
    }
  })
})

Respond with options

In some cases a responder may require the user to give more information. This can be done using the voiceBox.addChoice and voiceBox.choice methods.

First, you need to add a choice using the voiceBox.addChoice method. This works the exact same way as the voiceBox.addResponder method.

You can then respond asking for more information using the voiceBox.choice(message) method. This tells VoiceBox that we are asking for more information and will begin listening again after output of the message has finished.

voiceBox.addResponder(/give me options/i, function(){
  voiceBox.addChoice(/one|1/i, function(){
    voiceBox.respond('You selected option one')
  })

  voiceBox.addChoice(/two|2/i, function(){
    voiceBox.respond('You selected option two')
  })

  voiceBox.choice('Do you want option one or option two?')
})

Storing information

You can store information using the following methods

voiceBox.db.set('users_name', 'thomas')
voiceBox.db.get('users_name')

Todo

All the things

  • Better application structure
  • Improve documentation
  • Ability to change config to pull in responses as npm packages ( similar to how Hubot handles scripts )

## License VoiceBox is released under the MIT License.

Credits

The duckduckgo responder uses their awesome API

voicebox's People

Contributors

thomascullen avatar

Watchers

Brock Angelo avatar James Cloos avatar  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.