Initial commit

This commit is contained in:
2018-09-22 10:44:38 +08:00
commit eacb95c18a
723 changed files with 100993 additions and 0 deletions
@@ -0,0 +1,6 @@
var SpeechGrammar = function() {
this.src;
this.weight;
};
module.exports = SpeechGrammar;
@@ -0,0 +1,16 @@
var SpeechGrammarList = function(data) {
this._list = data;
this.length = this._list.length;
};
SpeechGrammarList.prototype.item = function(item) {
return this._list[item];
};
SpeechGrammarList.prototype.addFromUri = function(item) {
};
SpeechGrammarList.prototype.addFromString = function(item) {
};
module.exports = SpeechGrammarList;
@@ -0,0 +1,87 @@
var exec = require("cordova/exec");
/**
attribute SpeechGrammarList grammars;
attribute DOMString lang;
attribute boolean continuous;
attribute boolean interimResults;
attribute unsigned long maxAlternatives;
attribute DOMString serviceURI;
*/
var SpeechRecognition = function () {
this.grammars = null;
this.lang = "en";
this.continuous = false;
this.interimResults = false;
this.maxAlternatives = 1;
this.serviceURI = "";
// event methods
this.onaudiostart = null;
this.onsoundstart = null;
this.onspeechstart = null;
this.onspeechend = null;
this.onsoundend = null;
this.onaudioend = null;
this.onresult = null;
this.onnomatch = null;
this.onerror = null;
this.onstart = null;
this.onend = null;
this.ondebug = null;
this.onpartial = null;
exec(function() {
console.log("initialized");
}, function(e) {
console.error("error: " + e);
}, "SpeechRecognition", "init", []);
};
SpeechRecognition.prototype.start = function(suppressSound) {
var that = this;
var successCallback = function(event) {
if (event.type === "debug" && typeof that.ondebug === "function") {
that.ondebug(event);
} else if (event.type === "audiostart" && typeof that.onaudiostart === "function") {
that.onaudiostart(event);
} else if (event.type === "soundstart" && typeof that.onsoundstart === "function") {
that.onsoundstart(event);
} else if (event.type === "speechstart" && typeof that.onspeechstart === "function") {
that.onspeechstart(event);
} else if (event.type === "speechend" && typeof that.onspeechend === "function") {
that.onspeechend(event);
} else if (event.type === "soundend" && typeof that.onsoundend === "function") {
that.onsoundend(event);
} else if (event.type === "audioend" && typeof that.onaudioend === "function") {
that.onaudioend(event);
} else if (event.type === "result" && typeof that.onresult === "function") {
that.onresult(event);
} else if (event.type === "partial" && typeof that.onpartial === "function") {
that.onresult(event);
} else if (event.type === "nomatch" && typeof that.onnomatch === "function") {
that.onnomatch(event);
} else if (event.type === "start" && typeof that.onstart === "function") {
that.onstart(event);
} else if (event.type === "end" && typeof that.onend === "function") {
that.onend(event);
}
};
var errorCallback = function(err) {
if (typeof that.onerror === "function") {
that.onerror(err);
}
};
exec(successCallback, errorCallback, "SpeechRecognition", "start", [this.lang, this.interimResults, this.maxAlternatives, (suppressSound || false)]);
};
SpeechRecognition.prototype.stop = function() {
exec(null, null, "SpeechRecognition", "stop", []);
};
SpeechRecognition.prototype.abort = function() {
exec(null, null, "SpeechRecognition", "abort", []);
};
module.exports = SpeechRecognition;
@@ -0,0 +1,6 @@
var SpeechRecognitionAlternative = function() {
this.transcript = null;
this.confidence = 0.0;
};
module.exports = SpeechRecognitionAlternative;
@@ -0,0 +1,15 @@
var SpeechRecognitionError = function() {
this.error = null;
this.message = null;
};
SpeechRecognitionError['no-speech'] = 0;
SpeechRecognitionError['aborted'] = 1;
SpeechRecognitionError['audio-capture'] = 2;
SpeechRecognitionError['network'] = 3;
SpeechRecognitionError['not-allowed'] = 4;
SpeechRecognitionError['service-not-allowed'] = 5;
SpeechRecognitionError['bad-grammar'] = 6;
SpeechRecognitionError['language-not-supported'] = 7;
module.exports = SpeechRecognitionError;
@@ -0,0 +1,8 @@
var SpeechRecognitionEvent = function() {
this.resultIndex;
this.results;
this.interpretation;
this.emma;
};
module.exports = SpeechRecognitionEvent;
@@ -0,0 +1,12 @@
// A complete one-shot simple response
var SpeechRecognitionResult = function() {
this._result = [];
this.length = 0;
this.final = false;
};
SpeechRecognitionResult.prototype.item = function(item) {
return this._result[item];
};
module.exports = SpeechRecognitionResult;
@@ -0,0 +1,11 @@
// A collection of responses (used in continuous mode)
var SpeechRecognitionResultList = function() {
this._result = [];
this.length = 0;
};
SpeechRecognitionResultList.prototype.item = function(item) {
return this._result[item];
};
module.exports = SpeechRecognitionResultList;