-
Automated Closed Caption Tweak?
Hi, i’m using the code on this tutorial (pasted below). What it does is use the comments on the layer to display 5 words at a time for closed captions. This is great, however I have a monologue I’m trying to CC and there are many pauses – moments where the speaker is trying to take time – in her speech. The result of the expression below forces 5 words no matter what. So if the speaker says “Wait. (10 second pause) I’ve got something to say.” The CC will say “Wait. I’ve got something to” – “say”. Ideally, I’d like “Wait” to be on it’s own line and actually wait for the next line before showing up. Even if I have to do something manually I don’t mind, but currently it’s a real pain tricking it into breaking up pauses. Can anyone think of a tweak to this expression so I could modify it slightly?
L = thisComp.layer("text");
max = 5; // number of words to display
n = 0
if (L.marker.numKeys > 0){
n = L.marker.nearestKey(time).index;
if (L.marker.key(n).time > time){
n--;
}
}
s = " ";
if (n > 0){
base = Math.floor((n-1)/max)*max + 1;
for (i = base; i < base + max; i++){
if (i <= L.marker.numKeys){
s += L.marker.key(i).comment + " ";
}
}
}
s