How can I use Voice Control on Tizen Wearable Web Application?

179 views Asked by At

I'm trying to implement Voice Control into my app.
I followed this guide on the Tizen Docs.
I fixed some syntax errors in the guide's code, but it still didn't work. I don't get any errors, but the results don't show up.

Any help would be appreciated. Thanks.
Here is my code:

var initializeVoiceControlClient = () => {
  return tizen.voicecontrol.getVoiceControlClient();
};

/* Listener */
var languageChangeListenerCallback = function (previous, current) {
  console.log("Language change callback " + previous + "->" + current);
};

/* Add */
var addCurrentLanguageChanged = () => {
  var id = client.addLanguageChangeListener(languageChangeListenerCallback);
};

/* Remove */
var removeCurrentLanguageChanged = () => {
  var id = client.addLanguageChangeListener(languageChangeListenerCallback);

  client.removeLanguageChangeListener(id);
};

/* Listener */
var resultListenerCallback = function (event, list, result) {
  console.log("Result callback - event: " + event + ", result: " + result);
};

/* Add */
var addResultListener = () => {
  var id = client.addResultListener(resultListenerCallback);
};

/* Remove */
var removeResultListener = () => {
  var id = client.addResultListener(resultListenerCallback);

  client.removeResultListener(id);
};

var createCommandList = () => {
  var command = new tizen.VoiceControlCommand("hello");
  var commands = [command];
  client.setCommandList(commands);
};

var getCurrentLang = () => {
  var currentLanguage = client.getCurrentLanguage();
  console.log("Current language is: " + currentLanguage);

  /*
       Expected output:
       Current language is: en_US
    */
};

var client = initializeVoiceControlClient();
createCommandList();
getCurrentLang();
addResultListener();
0

There are 0 answers