/// <summary>
        /// Builds ToBI informaiton.
        /// </summary>
        /// <param name="mapWords">The map of script word and tts word.</param>
        private void BuildToBIInformation(Dictionary<ScriptWord, TtsWord> mapWords)
        {
            if (NeedToBI)
            {
                TtsTobiAccentSet accentSet = new TtsTobiAccentSet();
                TtsTobiBoundaryToneSet boundaryToneSet = new TtsTobiBoundaryToneSet();

                foreach (KeyValuePair<ScriptWord, TtsWord> pair in mapWords)
                {
                    // Builds ToBI accent if needs.
                    Collection<ScriptSyllable> scriptSyllables = pair.Key.Syllables;
                    TtsSyllable syllable = pair.Value.FirstSyllable;

                    foreach (ScriptSyllable scriptSyllable in scriptSyllables)
                    {
                        if (scriptSyllable.TobiPitchAccent != null)
                        {
                            syllable.ToBIAccent = (TtsTobiAccent)accentSet.Items[scriptSyllable.TobiPitchAccent.Label];
                        }

                        syllable = syllable.Next;
                    }

                    // Build ToBI boudary tone
                    // pair.ScriptWord.TobiFinalBoundaryTone
                    if (pair.Key.TobiFinalBoundaryTone != null)
                    {
                        pair.Value.ToBIFinalBoundaryTone = (TtsTobiBoundaryTone)boundaryToneSet.Items[pair.Key.TobiFinalBoundaryTone.Label];
                    }
                }
            }
        }
        /// <summary>
        /// Dump the data in the syllable.
        /// </summary>
        /// <param name="scriptWord">The script word to store the data dumped from the syllables.</param>
        /// <param name="utt">The utterance.</param>
        /// <param name="word">The word which contains the these syllables.</param>
        /// <param name="phoneIndex">Phone index to mark the phone in the Utt.Phones.</param>
        /// <param name="unitIndex">Unit index to mark the unit in the Utt.Units.</param>
        /// <param name="f0StartIndex">F0 index to mark the start position in the F0s.</param>
        /// <param name="ttsEngine">The object ttsEngine to help to convert the Pos and get sentence id.</param>
        private static void DumpSyllables(ScriptWord scriptWord, SP.TtsUtterance utt,
            SP.TtsWord word, ref int phoneIndex, ref int unitIndex, ref int f0StartIndex, SP.TtsEngine ttsEngine)
        {
            Debug.Assert(scriptWord != null, "ScriptWord should not be null");
            Debug.Assert(utt != null, "Utt should not be null");
            Debug.Assert(word != null, "Word should not be null");
            Debug.Assert(phoneIndex >= 0, "PhoneIndex should not be less than 0");
            Debug.Assert(f0StartIndex >= 0, "f0StartIndex should not be less than 0");
            Debug.Assert(ttsEngine != null, "ttsEngine should not be null");

            // Go through each syllable in the word.
            SP.TtsSyllable syllable = word.FirstSyllable;
            while (syllable != null)
            {
                ScriptSyllable scriptSyllable = new ScriptSyllable();
                TtsTobiAccentSet tobiAccentSet = new TtsTobiAccentSet();
                if (syllable.ToBIAccent != SP.TtsTobiAccent.K_NOACC)
                {
                    scriptSyllable.TobiPitchAccent = TobiLabel.Create(tobiAccentSet.IdItems[(uint)syllable.ToBIAccent]);
                }

                scriptSyllable.Stress = (TtsStress)syllable.Stress;
                DumpPhones(scriptSyllable, utt, syllable, ref phoneIndex, ref unitIndex, ref f0StartIndex, ttsEngine);
                scriptWord.Syllables.Add(scriptSyllable);
                if (syllable == word.LastSyllable)
                {
                    break;
                }

                syllable = syllable.Next;
            }
        }
        /// <summary>
        /// Update ToBIAccent.
        /// </summary>
        /// <param name="utt">Tts utterance.</param>
        /// <param name="scriptSentence">Script sentence.</param>
        private static void UpdateToBIAccent(SP.TtsUtterance utt, ScriptSentence scriptSentence)
        {
            int uttWordCount = 0;
            TtsTobiAccentSet accentSet = new TtsTobiAccentSet();

            System.Console.WriteLine("warning: update the ToBIAccent!");
            foreach (ScriptWord scriptWord in scriptSentence.Words)
            {
                if (scriptWord.IsPronounced)
                {
                    SP.TtsWord uttWord;
                    while (!(uttWord = utt.Words[uttWordCount++]).IsPronounceable)
                    {
                    }

                    Collection<ScriptSyllable> scriptSyllables = scriptWord.Syllables;
                    SP.TtsSyllable thisSyllable = uttWord.FirstSyllable;
                    foreach (ScriptSyllable scriptSyllable in scriptSyllables)
                    {
                        if (scriptSyllable.TobiPitchAccent != null)
                        {
                            thisSyllable.ToBIAccent = (SP.TtsTobiAccent)accentSet.Items[scriptSyllable.TobiPitchAccent.Label];
                        }

                        thisSyllable = thisSyllable.Next;
                    }
                }
            }
        }