ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Syncing text to audio

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Henri Yates
Syncing text to audio
on Jan 10, 2020 at 2:52:52 pm

Hi.. I wanted to sync my voice-over with markers aligned perfectly to each word said in the VO. I want to sync the VO with its corresponding text to the text appears as the word is being spoken... I tried using expressions but it doesn't sync perfectly. Is there a mistake in my expression or my expression is completely wrong.
Here's my code
4a642036-d23e-42ff-84f2-06b40e5fb39b.png.jpg

Thanks,
Cheers.

// TypeMonkey
m = thisComp.layer("1.mp3").marker;
rate = 20;
n = text.sourceText.length;
d = n/rate;
pre = d/2;
t = time
n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time){
n--;
}
}

if (n == 0){
0
}else{
m = marker.key(n);
myComment = m.comment;
t = time - m.time;
try{
actMarker = action.marker.key(myComment);
if (action.marker.numKeys > actMarker.index){
tMax = action.marker.key(actMarker.index + 1).time - actMarker.time;
}else{
tMax = action.outPoint - actMarker.time;
}
t = Math.min(t, tMax);
actMarker.time + t;
}catch (err){
0
}
}
linear(t,0,d,0,100)


Return to posts index

Dan Ebberts
Re: Syncing text to audio
on Jan 10, 2020 at 8:02:43 pm

It looks like maybe you took several unrelated expressions and mooshed them together somehow. In any case, this should give you one basic way to sync the text to the markers:


m = thisComp.layer("1.mp3").marker;
n = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time){
n--;
}
}
if (n == 0){
""
}else{
m.key(n).comment;
}



Dan



Return to posts index

Henri Yates
Re: Syncing text to audio
on Jan 10, 2020 at 9:56:06 pm

Thanks for replying sir.
I tried your solution. Unfortunately, it didn't work. It gave me this error;

After Effect warning: an expression was disabled as a result of an error.

Error at line 0 in property 'Start' of layer 5 ('layer name') in comp '5'.
invalid numeric result (divide by zero?).


What do you suggest I should do?

Thanks again.
Cheers


Return to posts index


Dan Ebberts
Re: Syncing text to audio
on Jan 10, 2020 at 10:54:29 pm

Sorry, I don't notice you had the expression applied to a range selector. I assumed the text was coming from the markers, so that expression is for the Source Text property.

Dan



Return to posts index

Dan Ebberts
Re: Syncing text to audio
on Jan 14, 2020 at 12:25:12 am

Henri,

I got your emails, but my replies get returned immediately with a permanent error rejection message. I'm not sure why, but I'll post here instead.

What you're describing is a lot trickier, because the expression has to be able to figure out how many characters were used in all the words triggered by previous markers. Not impossible, but considerably more complicated. I don't have the time to do it right now, but maybe someone can crank it out for you.

Dan



Return to posts index

Henri Yates
Re: Syncing text to audio
on Jan 14, 2020 at 8:44:51 am

Oh bummer, but thank you sir. I appreciate your help so much.
Cheers.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]