cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Voice commands & script(Application Events inside 3D Eyewear projects)

TomasCharvat
14-Alexandrite

Voice commands & script(Application Events inside 3D Eyewear projects)

Hello frends,

 

Is it possible to change or create voice commands from javascript?

For example: is it possible to change Voice Response based on called function result?

 

Thanks for any response.

 

Tomas

1 ACCEPTED SOLUTION

Accepted Solutions

If your use case is to change the voice response, you could maybe tackle it by not using voice response, but using text-to-speech in your JS function. For example, if your command is "Show Voltage", and you want the response to be "Reading is X Volts" (where X is some data read from the device), you could try something like this:

 

* Define the voice command to run viewCtrl.showVoltage()

* Leave the Voice Response field in the Application Event blank

* In your code, have something like this:

 

$scope.showVoltage = function() {
  // assume the IoT data is bound to the "voltage" app param
  // show the Voltage label
  $scope.setWidgetProp("voltage", "visible", true);
  // set the label
  $scope.setWidgetProp("voltage", "text", $scope.app.params["voltage"] + "V");
  // say the result
  $scope.app.speech.synthesizeSpeech({'text': 'Reading is ' + $scope.app.params["voltage"] + " volts"});
}

 

View solution in original post

3 REPLIES 3

Hi @TomasCharvat ,

I do not know an option how to change  or to create definition of voice response at runtime. Possibly somebody could post further details.

I want only to mentioned that  one time the voice response was defined - you can change later at runtime that what it does. Means the same command will perform different functions depending on runtime setting

So let say the voice command will call a function define in the Home.js - let say test function.

In this case you could change the behavior of the test function  e.g. using select case (switch case) which check some parameter

or using  eval function use different function definitions

 

let functionName= 'setShadeStrWaterWaveLev' 
let strShaderWaterWaveLev 		=eval("$scope."+functionName.trim() + "("+newscale1+","+wlevel+",false,LEVEL_ZERO);") ;  

 

 

If your use case is to change the voice response, you could maybe tackle it by not using voice response, but using text-to-speech in your JS function. For example, if your command is "Show Voltage", and you want the response to be "Reading is X Volts" (where X is some data read from the device), you could try something like this:

 

* Define the voice command to run viewCtrl.showVoltage()

* Leave the Voice Response field in the Application Event blank

* In your code, have something like this:

 

$scope.showVoltage = function() {
  // assume the IoT data is bound to the "voltage" app param
  // show the Voltage label
  $scope.setWidgetProp("voltage", "visible", true);
  // set the label
  $scope.setWidgetProp("voltage", "text", $scope.app.params["voltage"] + "V");
  // say the result
  $scope.app.speech.synthesizeSpeech({'text': 'Reading is ' + $scope.app.params["voltage"] + " volts"});
}

 

yes, that's the real  solution. In the question was asked about voice response - but what I meant in my answer  (my mistake) -> was the voice command definition (the text what we need to say to start the command) thanks for clarification.

Top Tags