Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Right now by default, at each step of a sequence the user is read the title of the step with the code below:
var instruction = '';
$scope.$on('newStep', function(evt, arg) {
instruction = arg
});
$scope.SayStep = function () {
$scope.app.speech.synthesizeSpeech({'text': instruction});
}
However, I want to add a button that will play all steps to give the user an overview. At each step, I would like those instructions to be read.
My first thought was to change the method of speech playback to trigger on a listener for step complete, but I'm unsure if that's the best method.
Thoughts?
Solved! Go to Solution.
Hi @Aouellets ,
in on of my project I useds some approach :
//==================================
$scope.app.playAudio = function (mp3) {
var audio = new Audio(mp3);
audio.addEventListener('ended', function() {
console.warn("mp3="+mp3+" finished!")
console.warn("call the next audio from the list");
}, false);
let wdgName = 'label-3'
let volume =parseFloat($scope.view.wdg[wdgName].text)
audio.volume = volume;
audio.play();
};
//==================================
$scope.$on('stepstarted', function(evt, arg1, arg2, arg3) {
var parsedArg3 = JSON.parse(arg3);
//some debugings
console.log("stepName="+parsedArg3.stepName);
console.log("stepDescription="+parsedArg3.stepDescription);
console.log("nextStep="+parsedArg3.nextStep);
$scope.stepDescription=parsedArg3.stepDescription;
console.warn("Event: " + evt.name + " arg3 fields, name: " + parsedArg3.stepName + " duration(ms): " + parsedArg3.duration + " total steps: " + parsedArg3.totalSteps + " step desc: " + parsedArg3.stepDescription );
$scope.app.playAudio('app/resources/Uploaded/seq_step_'+parsedArg3.stepNumber+'.mp3');
});
There I used step started but you can also used stepcompleted event. I remember that one of the parameter values was not available in step started but only step completed (I could not rember exactly which one). You can test it simple ;
$scope.$on('stepcompleted',/*stepstarted*/ function(evt, arg1, arg2, arg3) {
var parsedArg3 = JSON.parse(arg3);
console.warn(evt);
console.warn(arg1);
console.warn(arg2);
console.warn(arg3); })
Hi @Aouellets ,
in on of my project I useds some approach :
//==================================
$scope.app.playAudio = function (mp3) {
var audio = new Audio(mp3);
audio.addEventListener('ended', function() {
console.warn("mp3="+mp3+" finished!")
console.warn("call the next audio from the list");
}, false);
let wdgName = 'label-3'
let volume =parseFloat($scope.view.wdg[wdgName].text)
audio.volume = volume;
audio.play();
};
//==================================
$scope.$on('stepstarted', function(evt, arg1, arg2, arg3) {
var parsedArg3 = JSON.parse(arg3);
//some debugings
console.log("stepName="+parsedArg3.stepName);
console.log("stepDescription="+parsedArg3.stepDescription);
console.log("nextStep="+parsedArg3.nextStep);
$scope.stepDescription=parsedArg3.stepDescription;
console.warn("Event: " + evt.name + " arg3 fields, name: " + parsedArg3.stepName + " duration(ms): " + parsedArg3.duration + " total steps: " + parsedArg3.totalSteps + " step desc: " + parsedArg3.stepDescription );
$scope.app.playAudio('app/resources/Uploaded/seq_step_'+parsedArg3.stepNumber+'.mp3');
});
There I used step started but you can also used stepcompleted event. I remember that one of the parameter values was not available in step started but only step completed (I could not rember exactly which one). You can test it simple ;
$scope.$on('stepcompleted',/*stepstarted*/ function(evt, arg1, arg2, arg3) {
var parsedArg3 = JSON.parse(arg3);
console.warn(evt);
console.warn(arg1);
console.warn(arg2);
console.warn(arg3); })
Hi Roland,
This implementation works for me if I have audio files being played, but not if I'm using speech synthesis.
Is there any event that I can detect when the HoloLens is done reading speech to then proceed to playing the next step?
I am trying to read the instructions for each step programmatically instead of uploading files for each step.