Example #1
0
        public void Coalesce()
        {
            List <PapagayoPhoneme> eventList        = new List <PapagayoPhoneme>();
            List <PapagayoPhoneme> newList          = new List <PapagayoPhoneme>();
            PapagayoPhoneme        coalescedPhoneme = null;
            PapagayoPhoneme        newPhoneme       = null;

            for (int eventIndex = 0; eventIndex < SoundFrames; eventIndex++)
            {
                eventList.Add(this.GetEventPhoneme(eventIndex));
            }

            foreach (PapagayoPhoneme phoneme in eventList)
            {
                if (coalescedPhoneme == null)
                {
                    coalescedPhoneme = phoneme;
                }

                if (coalescedPhoneme.Type == phoneme.Type)
                {
                    coalescedPhoneme.EndFrame = phoneme.EndFrame;
                }
                else
                {
                    newPhoneme = new PapagayoPhoneme(coalescedPhoneme);
                    newList.Add(newPhoneme);
                    coalescedPhoneme = phoneme;
                }
            }
            newList.Add(new PapagayoPhoneme(coalescedPhoneme));

            m_phonemes = newList;
        }
Example #2
0
        public PapagayoPhoneme(string pair, PapagayoPhoneme lastObj)
        {
            m_type = PhonemeType.REST;
            m_Text = "Rest";
            if (pair != null)
            {
                string[] split = pair.Split(' ');
                if (split.Length == 2)
                {
                    StartFrame = Convert.ToInt32(split[0].TrimStart(null));
                    m_Text     = split[1].TrimStart(null);
                    try
                    {
                        m_type = (PhonemeType)Enum.Parse(typeof(PhonemeType), m_Text);
                    }
                    catch (Exception)
                    {
                        m_type = PhonemeType.REST;
                    }

                    if (lastObj != null)
                    {
                        lastObj.EndFrame = StartFrame - 1;
                    }
                }
            }
        }
Example #3
0
 public PapagayoPhoneme(PapagayoPhoneme copyObj)
 {
     this.m_state    = copyObj.m_state;
     this.m_Text     = copyObj.m_Text;
     this.StartFrame = copyObj.StartFrame;
     this.EndFrame   = copyObj.EndFrame;
     this.m_type     = copyObj.m_type;
 }
Example #4
0
        public PapagayoPhoneme GetEventPhoneme(int eventNum)
        {
            foreach (PapagayoWord word in this.m_words)
            {
                if (eventNum >= word.StartFrame &&
                    eventNum <= word.EndFrame)
                {
                    return(word.GetEventPhoneme(eventNum));
                }
            }
            PapagayoPhoneme defaultPhoneme = new PapagayoPhoneme(null, null);

            defaultPhoneme.StartFrame = eventNum;
            defaultPhoneme.EndFrame   = eventNum;
            return(defaultPhoneme);
        }
Example #5
0
        public PapagayoPhoneme GetEventPhoneme(string voiceStr, int eventNum)
        {
            PapagayoPhoneme retVal = null;

            try
            {
                PapagayoVoice voice = m_voices[voiceStr.Trim()];
                if (voice != null)
                {
                    retVal = voice.GetEventPhoneme(eventNum);
                }
            }
            catch (KeyNotFoundException) { }

            return(retVal);
        }
Example #6
0
        public PapagayoPhoneme GetEventPhoneme(int eventNum)
        {
            foreach (PapagayoPhoneme phoneme in m_phoneme)
            {
                if (eventNum >= phoneme.StartFrame &&
                    eventNum <= phoneme.EndFrame)
                {
                    return(phoneme);
                }
            }

            PapagayoPhoneme defaultPhoneme = new PapagayoPhoneme(null, null);

            defaultPhoneme.StartFrame = eventNum;
            defaultPhoneme.EndFrame   = eventNum;
            return(defaultPhoneme);
        }
Example #7
0
        public PapagayoWord(StreamReader file,
                            ref List <PapagayoPhoneme> phonemes)
        {
            line = file.ReadLine();
            if (line == null)
            {
                throw new IOException("Corrupt File Format");
            }

            line = line.TrimStart(null);
            string[] split = line.Split(' ');
            if (split.Length == 4)
            {
                m_wordText   = split[0].TrimStart(null);
                StartFrame   = Convert.ToInt32(split[1].TrimStart(null));
                EndFrame     = Convert.ToInt32(split[2].TrimStart(null));
                m_numPhoneme = Convert.ToInt32(split[3].TrimStart(null));
                m_phoneme    = new PapagayoPhoneme[m_numPhoneme];

                PapagayoPhoneme lastObj = null;
                for (int j = 0; j < m_numPhoneme; j++)
                {
                    if ((line = file.ReadLine()) != null)
                    {
                        line         = line.TrimStart(null);
                        m_phoneme[j] = new PapagayoPhoneme(line, lastObj);
                        lastObj      = m_phoneme[j];
                        phonemes.Add(m_phoneme[j]);
                    }
                }

                if (lastObj != null)
                {
                    lastObj.EndFrame = EndFrame;
                }
            }
        }
Example #8
0
        public PapagayoPhoneme(string pair, PapagayoPhoneme lastObj)
        {
            m_type = PhonemeType.REST;
            m_Text = "Rest";
            if (pair != null)
            {
                string[] split = pair.Split(' ');
                if (split.Length == 2)
                {
                    StartFrame = Convert.ToInt32(split[0].TrimStart(null));
                    m_Text = split[1].TrimStart(null);
                    try
                    {
                        m_type = (PhonemeType)Enum.Parse(typeof(PhonemeType), m_Text);
                    }
                    catch (Exception)
                    {
                        m_type = PhonemeType.REST;
                    }

                    if (lastObj != null)
                    {
                        lastObj.EndFrame = StartFrame - 1;
                    }
                }

            }

        }
Example #9
0
 public PapagayoPhoneme(PapagayoPhoneme copyObj)
 {
     this.m_state = copyObj.m_state;
     this.m_Text = copyObj.m_Text;
     this.StartFrame = copyObj.StartFrame;
     this.EndFrame = copyObj.EndFrame;
     this.m_type = copyObj.m_type;
 }
Example #10
0
        public PapagayoPhoneme GetEventPhoneme(int eventNum)
        {
            foreach (PapagayoPhoneme phoneme in m_phoneme)
            {
                if (eventNum >= phoneme.StartFrame &&
                    eventNum <= phoneme.EndFrame)
                {
                    return phoneme;
                }
            }

            PapagayoPhoneme defaultPhoneme = new PapagayoPhoneme(null, null);
            defaultPhoneme.StartFrame = eventNum;
            defaultPhoneme.EndFrame = eventNum;
            return defaultPhoneme;
        }
Example #11
0
        public PapagayoWord(StreamReader file,
            ref List<PapagayoPhoneme> phonemes)
        {
            line = file.ReadLine();
            if (line == null)
            {
                throw new IOException("Corrupt File Format");
            }

            line = line.TrimStart(null);
            string[] split = line.Split(' ');
            if (split.Length == 4)
            {
                m_wordText = split[0].TrimStart(null);
                StartFrame = Convert.ToInt32(split[1].TrimStart(null));
                EndFrame = Convert.ToInt32(split[2].TrimStart(null));
                m_numPhoneme = Convert.ToInt32(split[3].TrimStart(null));
                m_phoneme = new PapagayoPhoneme[m_numPhoneme];

                PapagayoPhoneme lastObj = null;
                for (int j = 0; j < m_numPhoneme; j++)
                {
                    if ((line = file.ReadLine()) != null)
                    {
                        line = line.TrimStart(null);
                        m_phoneme[j] = new PapagayoPhoneme(line, lastObj);
                        lastObj = m_phoneme[j];
                        phonemes.Add(m_phoneme[j]);
                    }
                }

                if (lastObj != null)
                {
                    lastObj.EndFrame = EndFrame;
                }
            }
        }
Example #12
0
 public PapagayoPhoneme GetEventPhoneme(int eventNum)
 {
     foreach (PapagayoWord word in this.m_words)
     {
         if (eventNum >= word.StartFrame &&
             eventNum <= word.EndFrame)
         {
             return word.GetEventPhoneme(eventNum);
         }
     }
     PapagayoPhoneme defaultPhoneme = new PapagayoPhoneme(null, null);
     defaultPhoneme.StartFrame = eventNum;
     defaultPhoneme.EndFrame = eventNum;
     return defaultPhoneme;
 }
Example #13
0
        public void Coalesce()
        {
            List<PapagayoPhoneme> eventList = new List<PapagayoPhoneme>();
            List<PapagayoPhoneme> newList = new List<PapagayoPhoneme>();
            PapagayoPhoneme coalescedPhoneme = null;
            PapagayoPhoneme newPhoneme = null;
            for (int eventIndex = 0; eventIndex < SoundFrames; eventIndex++)
            {
                eventList.Add(this.GetEventPhoneme(eventIndex));
            }

            foreach(PapagayoPhoneme phoneme in eventList)
            {
                if (coalescedPhoneme == null)
                {
                    coalescedPhoneme = phoneme;
                }

                if (coalescedPhoneme.Type == phoneme.Type)
                {
                    coalescedPhoneme.EndFrame = phoneme.EndFrame;
                }
                else
                {
                    newPhoneme = new PapagayoPhoneme(coalescedPhoneme);
                    newList.Add(newPhoneme);
                    coalescedPhoneme = phoneme;
                }

            }
            newList.Add(new PapagayoPhoneme(coalescedPhoneme));

            m_phonemes = newList;
        }