Skip to content

Easy library for voice commands using machine learning in javascript

Notifications You must be signed in to change notification settings

luukfroling/voiceCommand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

voiceCommand

Easy library for voice commands using machine learning in javascript

The library was written with the intention of being easy to use for people with no machine learning background. The network configuration (amount of layers/nodes) it the only machine learning related setting of the library.

Documentation

Initialise the network

nn = new neuralNetwork([27, H1, H2, O]);

Pass an array as a parameter which function as the network configuration. The first element will be the amount of input nodes and must be 27 nodes. The last layer is the output layer and must be the length of the function array we will pass to the network later on. All the layers inbetween are hidden layers.

setOutput

nn.setOutput(outputF);

Every output node must be linked to a function. The array of funtions must be the same size as the amount of output nodes. The output node with the highest value will decide what function will be excecuted. If output 1 turns out to be the highest probability, function[1] is excecuted. OutputF template:

let outputF = [
  function(){
    console.log("executed if node 0 of the output layer has the highest value")
  },
  function(){
    console.log("executed if node 1 of the output layer has the highest value")
  }
]

setData

nn.setData(data);

the setData expects an array with training data. The training data consists of a sentence linked to an output. The sentence can be of any size with any lowercase character from the alphabet. Data template:

let data = [
  ["Output zero", 0],
  ["Output one", 1]
]

run

nn.run(str);

A function which lets the neural network make a guess based on the tex passed as parameter. The run function will automatically execute one of the outputfunctions set with the setOutput command. The input string can also be automatically formed from speech with the web speech API described below.

setRecognition

nn.setRecognition(cont);

Initialises the part of the neural network library which uses the web speech API to recognise text and automatically run the network on the input. setRecognition does not start the recognition yet. cont is a boolean parameter which allows the user to control wether the program should stop listening after a succesful recognition. Set cont true if the recognition should continue untill stopRecognition is called, otherwise set false.

beginRecognition

nn.beginRecognition();

This will begin the recognition. The next time speech is recognised the neural network will run on the resulting sentence.

endRecognition

nn.endRecognition();

A function to end the speech recognition while using continuous mode.

'In depth' explanation

The network uses a LSTM cell between the input and first hidden layer to process series of data like a string

TODO: finish this.

About

Easy library for voice commands using machine learning in javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published