コード例 #1
0
        public List <ScriptableObject> ExtractVisemes(string[] text)
        {
            try
            {
                List <ScriptableObject> visemes = new List <ScriptableObject>();

                for (int i = 0; i < text.Length; i++)
                {
                    text[i]        = text[i].Substring(1);
                    phonemes       = text[i].Split(')')[0].Trim();
                    timings        = text[i].Split(')')[1].Trim();
                    phonemesInWord = phonemes.Split(' ');
                    for (int j = 0; j < phonemesInWord.Length; j++)
                    {
                        phonemeToVisemeDictionary = CreateDictionary();
                        if (phonemeToVisemeDictionary.ContainsKey(phonemesInWord[j]))
                        {
                            Viseme currentViseme = phonemeToVisemeDictionary[phonemesInWord[j]];
                            GetVisemeTimings(currentViseme, int.Parse(timings.Split(':')[0]), int.Parse(timings.Split(':')[1]), phonemesInWord.Length, j);
                            visemes.Add(currentViseme);
                        }
                    }
                }
                DataCleaning.LoadingBarViewer.Instance.SetNextPhase();
                return(visemes);
            }
            catch (System.Exception e)
            {
                Debug.Log("Viseme extration failed\n" + e);
                return(null);
            }
        }
コード例 #2
0
        private void GetVisemeTimings(Viseme viseme, int startTime, int endTime, int amountOfPhonemesInWord, int index)
        {
            int interval       = endTime - startTime;
            int visemeDuration = Mathf.RoundToInt(interval / amountOfPhonemesInWord);

            viseme.startTime = startTime + visemeDuration * index;
            viseme.endTime   = startTime + visemeDuration * (index + 1);
        }