Using observables for lip syncing

Okay I’ll try that

Just for clarification by hook into onBeforeRenderObservable do you mean use scene.onBeforeRenderObservable and have the time counter inside of it or do you mean something else?

exactly this :slight_smile:

And for the time counter do you mean like use a setTimeout function or use something like var startTime = performance.now();?

I’ve managed to create a time counter and the lip positions change while the sound is playing but not all the lip positions are happening at the time their supposed to. For example the lip positions are supposed to be (i, f, e, r, i, u, u, i, i, u) but not all of the lip positions that are suppose to happen are happening.

We would need a bit more info on the issues you are facing now ?

I’m trying to show a playground of it but I’ve come across another problem when I try to use a scene.onBeforeRenderObservable function with setCurrentVowel inside of it as well as the timer the lip positions don’t change. I’ve attached a playground of my problem below

The error is in your script not passing down the vowel value but the time: https://playground.babylonjs.com/#VU1G98#20

Just for clarification, by but the time do you mean that I should find a way to increment the variable alpha without skipping one of the time’s where alpha === obj[t][‘time’] or do you mean something else?

I mean time should be computed in time units, not in number of frames as you do here.

alpha should be something like alpha += engine.getDeltaTime() or similar and you should move to the next movement once you either reached or passed a step and if you are too far ahead you might even want to skip some moves.