A speech recognition library for the web
JuliusJS is an opinionated port of Julius to JavaScript.
It actively listens to the user to transcribe what they are saying through a callback.
// bootstrap JuliusJS
var julius = new Julius();
julius.onrecognition = function(sentence) {
console.log(sentence);
};
// say "Hello, world!"
// console logs: `> HELLO WORLD`
- Real-time transcription
- Use the provided grammar, or write your own
- 100% JavaScript implementation
- All recognition is done in-browser through a
Worker
- Familiar event-inspired API
- No external server calls
- Grab the latest version with bower
bower install juliusjs --save
- Include
julius.js
in your html
<script src="julius.js"></script>
- Make the scripts available to the client through your server
var express = require('express'),
app = express();
app.use(express.static('path/to/dist'));
- In your main script, bootstrap JuliusJS and register an event listener for recognition events
// bootstrap JuliusJS
var julius = new Julius();
// register listener
julius.onrecognition = function(sentence) {
// ...
console.log(sentence);
};
- Your site now has real-time speech recognition baked in!
In order for JuliusJS to use it, your grammar must follow the Julius grammar specification. The site includes a tutorial on writing grammars.
By default, phonemes are defined in bin/hmmdefs
, though you might find other sites more useful as reference.
- Building your own grammar requires the
mkdfa.pl
script and associated binaries, distributed with Julius. - On Mac OS X
- Use
./bin/mkdfa.pl
, included with this repo
- Use
- On other OS
- Run
emscripten.sh
to populatebin
with the necessary files
- Run
- Write a
yourGrammar.voca
file with words to be recognized
- The
.voca
file defines "word candidates" and their pronunciations.
- Write a
yourGrammar.grammar
file with phrases composed of those words
- The
.grammar
file defines "category-level syntax, i.e. allowed connection of words by their category name."
- Compile the grammar using
./bin/mkdfa.pl yourGrammar
- The
.voca
and.grammar
must be prefixed with the same name - This will generate
yourGrammar.dfa
andyourGrammar.dict
- Give the new
.dfa
and.dict
files to theJulius
constructor
// when bootstrapping JuliusJS
var julius = new Julius('path/to/dfa', 'path/to/dict');
- Contributions are welcome! See
CONTRIBUTING.md
for guidelines.
If you use JuliusJS
let me know, and I'll add your project to this list.
- Coming soon...
JuliusJS is a port of the "Large Vocabulary Continuous Speech Recognition Engine Julius" to JavaScript