Example #1
0
        PhonemePositions GetPhonemesFromMohoText(string text)
        {
            PhonemePositions pos = new PhonemePositions();

            string[] lines = text.Split('\n');

            int lineCount = 0;

            foreach (string line in lines)
            {
                if (lineCount != 0) // first line contains descriptive text
                {
                    string[] lineParts = line.Split(' ');

                    if (string.IsNullOrEmpty(lineParts[0]))
                    {
                        break;
                    }

                    float ms = int.Parse(lineParts[0]);

                    ms /= 24f; // 24 FPS

                    string phoneme = lineParts[1];

                    pos.Add(new PhonemePosition(ms, phoneme));

                    try
                    {
                        if (lineParts.Length > 2 && !string.IsNullOrEmpty(lineParts[2]))
                        {
                            pos.AddMood(new MoodPosition(ms, (CharacterHead.Moods) int.Parse(lineParts[2].Trim())));
                        }
                    }
                    catch { }

                    try
                    {
                        //if(lineParts.Length > 3 && !string.IsNullOrEmpty(lineParts[3])) pos.AddMode( new ModePosition(ms, (ElroyAdv.ArmGestures)int.Parse( lineParts[3].Trim ())) );
                    }
                    catch { }
                }

                lineCount++;
            }

            return(pos);
        }
Example #2
0
        protected PhonemePositions GetPhonemesFromLipSyncData(LipSyncData data, float audioClipLength)
        {
            PhonemePositions pos = new PhonemePositions();

            foreach (var phonemeMarker in data.phonemeData)
            {
                pos.Add(new PhonemePosition(phonemeMarker.time * audioClipLength, phonemes[phonemeMarker.phonemeNumber]));
            }

            foreach (var emotionMarker in data.emotionData)
            {
                pos.AddMood(new MoodPosition(emotionMarker.startTime * audioClipLength, GetMoodFromString(emotionMarker.emotion)));
                pos.AddMood(new MoodPosition(emotionMarker.endTime * audioClipLength, CharacterHead.Moods.Neutral));
            }

            foreach (var gestureMarker in data.gestureData)
            {
                pos.AddMode(new ModePosition(gestureMarker.time * audioClipLength, gestureMarker.gesture));
            }

            return(pos);
        }