Highlighted

Dynamic Lip Syncing with AS3

Community Beginner ,
Feb 28, 2019

Copy link to clipboard

Copied

So I come today with a question,

Does anyone have a way to dynamically lip sync audio with a MovieClip? I have built something that works until roughly the last 30 seconds of the audio clip. I'll provide what I've created below and then continue on the topic.

var embededTalkieData = {INTRO_001:[{s:0.118492, e:0.118492, v:"A"},

{s:0.251698, e:0.251698, v:"E"},

{s:0.370964, e:0.370964, v:"C_S"},

{s:0.457703, e:0.457703, v:"A"},

{s:0.630407, e:0.630407, v:"M_B_P"},

{s:0.801561, e:0.801561, v:"C_S"},

{s:0.928572, e:0.928572, v:"Sys-11"},

{s:1.018409, e:1.018409, v:"C_S"},

{s:1.801561, e:1.185691, v:"Sys-11"},

{s:1.276303, e:1.276303, v:"C_S"}]};

var lipsyncMouthInterval = setInterval(handleTalkieLipsync, 0.001);

var mouthIndex = 0;var talkie;

var talkieChannel;

var positionTimer:Timer;

function handleTalkieLipsync(actor)

{

if (embededTalkieData.INTRO_001.length > 1){

trace(embededTalkieData.INTRO_001.length);

trace(mouthIndex);

if(mouthIndex == embededTalkieData.INTRO_001.length){

trace("FROZEN!");

mouthIndex = 0;

actor.MovClip.art.mouths_mc.gotoAndStop(1);

actor.costumeIsTalking = false;

clearInterval(lipsyncMouthInterval);

return;

}

if(embededTalkieData.INTRO_001[mouthIndex].s){

var _loc2 = embededTalkieData.INTRO_001[mouthIndex];

var _loc3 = (talkieChannel.position / 1000);

if(_loc3 >= (_loc2.s)){

trace("handleTalkieLipsync() -> Has sound data, value:", _loc2.v);

actor.MovClip.art.mouths_mc.gotoAndStop(_loc2.v);

mouthIndex++;

}

}

}

}

So what happens is the code sets an Interval to constantly check the position of my audio clip which has an Audio Channel with the variable name "talkieChannel". While checking the position of the audio it runs through an Object called "embededTalkieData". Inside this Object is another Object called "INTRO_001" which contains keys with time codes in seconds as their values. Using the time codes in the Object it plays through and move the mouth to the right frame until like I said the last 30 seconds or so. The key "v" contains the name of a frame inside my mouth MovieClip. Maybe someone could tell me why this stops working close to the end of my audio clip.

I also tried Realtime lip-sync code snippet for Flash using AS3 | Pixel Envision Ltd. but it was not giving me the results I needed. I even tried modifying this to read the bytes and lip sync base off byte offset.

Does anyone have anything that can help me or answer why my code stops working? Thank you! _ 001

TOPICS
ActionScript

Views

149

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Dynamic Lip Syncing with AS3

Community Beginner ,
Feb 28, 2019

Copy link to clipboard

Copied

So I come today with a question,

Does anyone have a way to dynamically lip sync audio with a MovieClip? I have built something that works until roughly the last 30 seconds of the audio clip. I'll provide what I've created below and then continue on the topic.

var embededTalkieData = {INTRO_001:[{s:0.118492, e:0.118492, v:"A"},

{s:0.251698, e:0.251698, v:"E"},

{s:0.370964, e:0.370964, v:"C_S"},

{s:0.457703, e:0.457703, v:"A"},

{s:0.630407, e:0.630407, v:"M_B_P"},

{s:0.801561, e:0.801561, v:"C_S"},

{s:0.928572, e:0.928572, v:"Sys-11"},

{s:1.018409, e:1.018409, v:"C_S"},

{s:1.801561, e:1.185691, v:"Sys-11"},

{s:1.276303, e:1.276303, v:"C_S"}]};

var lipsyncMouthInterval = setInterval(handleTalkieLipsync, 0.001);

var mouthIndex = 0;var talkie;

var talkieChannel;

var positionTimer:Timer;

function handleTalkieLipsync(actor)

{

if (embededTalkieData.INTRO_001.length > 1){

trace(embededTalkieData.INTRO_001.length);

trace(mouthIndex);

if(mouthIndex == embededTalkieData.INTRO_001.length){

trace("FROZEN!");

mouthIndex = 0;

actor.MovClip.art.mouths_mc.gotoAndStop(1);

actor.costumeIsTalking = false;

clearInterval(lipsyncMouthInterval);

return;

}

if(embededTalkieData.INTRO_001[mouthIndex].s){

var _loc2 = embededTalkieData.INTRO_001[mouthIndex];

var _loc3 = (talkieChannel.position / 1000);

if(_loc3 >= (_loc2.s)){

trace("handleTalkieLipsync() -> Has sound data, value:", _loc2.v);

actor.MovClip.art.mouths_mc.gotoAndStop(_loc2.v);

mouthIndex++;

}

}

}

}

So what happens is the code sets an Interval to constantly check the position of my audio clip which has an Audio Channel with the variable name "talkieChannel". While checking the position of the audio it runs through an Object called "embededTalkieData". Inside this Object is another Object called "INTRO_001" which contains keys with time codes in seconds as their values. Using the time codes in the Object it plays through and move the mouth to the right frame until like I said the last 30 seconds or so. The key "v" contains the name of a frame inside my mouth MovieClip. Maybe someone could tell me why this stops working close to the end of my audio clip.

I also tried Realtime lip-sync code snippet for Flash using AS3 | Pixel Envision Ltd. but it was not giving me the results I needed. I even tried modifying this to read the bytes and lip sync base off byte offset.

Does anyone have anything that can help me or answer why my code stops working? Thank you! _ 001

TOPICS
ActionScript

Views

150

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 28, 2019 0

Have something to add?

Join the conversation