var args = { };
var obj = _dynamic_objects[msg.id];
if (!obj) {
+ /* Synthesizer events */
if (msg.event == 'pending') {
_v8tools.forceSetProperty(exports, 'pending', msg.state);
} else if (msg.event == 'speaking') {
} else if (msg.event == 'result') {
// currently we support only signle shot result
args.resultIndex = 0;
- args.results = msg.results;
args.interpretation = null;
args.emma = null;
+ var res = new SpeechRecognitionResult(msg.final);
+ msg.results.forEach(function(alternative) {
+ res.push({
+ 'transcript': alternative.transcript,
+ 'confidence': alternative.confidence
+ });
+ });
+ DBG('Result Length: ' + res.length);
+ args.results = [ res ];
} else if (msg.event == 'nomatch') {
args.resultIndex = 0;
args.results = null;
args.name = null;
}
} else if (msg.event == 'end') {
- if (obj.type == 'recognizer') {
+ if (obj._type == 'recognizer') {
} else {
args.charIndex = msg.charIndex;
args.elapsedTime = msg.elapsedTime;
// SpeechRecognition : Speech -> Text
//
function SpeechRecognitionResult(is_final) {
- this.push.apply(this, arguments);
- _addConstProperty(this, 'final', is_final || true);
+ _addConstProperty(this, 'isFinal', is_final || true);
this.item = function(index) {
return this[index];
};
-
- this.toJSON = function() {
- var a = [];
- for (var i = 0; i < this.length; i++) {
- a[i] = this[i];
- }
- return a;
- };
-
}
SpeechRecognitionResult.prototype = Object.create(Array.prototype);
SpeechRecognitionResult.prototype.construrctor = SpeechRecognitionResult;
function SpeechRecognition() {
this._id = -1;
this._is_active = 0;
+ this._type = 'recognizer';
EventTarget.call(this, [
'audiostart',
void SpeechInstance::SetupMainloop(void* data) {
SpeechInstance* self = reinterpret_cast<SpeechInstance*>(data);
+ DBG("Running Mainloop...");
+
g_main_loop_run(self->main_loop_);
}
#endif // TIZEN
, channel_(NULL)
, watcher_id_(0)
, pending_request_timer_(0)
- , pending_reply_timer_(0) {
+ , pending_reply_timer_(0)
+ , is_waiting_for_reply_(false) {
#ifdef TIZEN
thread_.detach();
#endif // TIZEN
char *reply = NULL;
uint32_t size = 0;
+ if (self->is_waiting_for_reply_) break;
+
if ((size = self->ReadReply(&reply))) {
self->PostMessage(reply);
free(reply);
obj["message"] = picojson::value("server connection failure");
out = picojson::value(obj);
} else {
+
+ is_waiting_for_reply_ = true;
picojson::parse(v, message, message + strlen(message), &err);
if (!err.empty())
return;
uint32_t size;
if ((size = ReadReply(&reply)) != 0) {
+ is_waiting_for_reply_ = false;
picojson::parse(out, reply, reply + size, &err);
free(reply);
if (!err.empty()) {