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); }
public void Load(string fileName) { string line; PapagayoVoice voice = null; m_state = 0; m_soundPath = null; PapagayoImportObject.SoundFrames = 0; m_numVoices = 0; m_voices.Clear(); StreamReader file = new StreamReader(fileName); while ((line = file.ReadLine()) != null) { //Trim leading whitespace on the read string. line = line.TrimStart(null); switch (m_state) { //Papagayo File Header case 0: if ((line.Contains("lipsync") == false)) { throw new IOException("Invalid File Format"); } else { m_state++; } break; //Read the sound path case 1: m_soundPath = line; m_state++; break; //Decode FPS case 2: PapagayoImportObject.FPS = Convert.ToInt32(line); m_state++; break; //Read the sound duration case 3: PapagayoImportObject.SoundFrames = Convert.ToInt32(line); m_state++; break; //Read the number of voices case 4: m_numVoices = Convert.ToInt32(line); for (int j = 0; j < m_numVoices; j++) { voice = new PapagayoVoice(); voice.EndFrame = PapagayoImportObject.SoundFrames; voice.Load(file); m_voices.Add(voice.VoiceName.Trim(), voice); } m_state++; break; default: throw new IOException(); } } m_fileNameStr = fileName; file.Close(); }