I am looking for a way to define what you expect the user to say in an tag
with the HTML 5
speech
attribute set.
I know that you
I found a way to do it client-side, using a new html5 feature: blobs.
window.URL = window.URL || window.webkitURL;
var myGrammar = new Blob(["My custom grammar"], {
type: 'text/xml Or whatever is the proper MIME type for grammars'});
var grammarUrl = window.URL.createObjectURL(myGrammar);
myInput = document.getElementById("myInput");
myInput.grammar = grammarUrl;
This makes a url out of the grammar string, and then sets that url for our input
element.
This way there is no need to make a server request, thus making it faster and less load on the server.
For more information on blobs, see this and this.