I'm trying to create an input field on the tablet of Pepper robot which allows user to input their email address by voice. I use a speech recognition box to get the letter that user says and raise an event so that Javascript can catch it and modify the text. But it seems that "document.getElementById("abc").value" never get what is currently on the screen but the defaut value.
Example: I say "1", it shows "hello1" (Totally good). Then I say "2", it shows "hello2" (Expecting "hello12")
Here is my JS code:
var session = new QiSession(function(session) {
// "Connection esterblished!";
}, function() {
// "Could not connect to the robot";
});
// Subscribe to ALMemory Service
session.service("ALMemory").then(function(ALMemory) {
// "ALMemory proxy subscription successful!";
ALMemory.getData('voice_input').then(function(voice_input){
document.getElementById("abc").value += voice_input;
});
});
HTML code:
<input type="text" name="email" id="abc" value="hello">
Is there anything to do with the "session"? Because even if I use a global variable to store the voice inputs, I can only modify the value of this variable but cannot get the current value of this variable inside the fonction(what I can get is the initialized value).