コード例 #1
0
        /// <summary>
        /// Append unit in one UnitListDictionary to an existing one.
        /// </summary>
        /// <param name="unitListDic">UnitListDictionary to be added.</param>
        public void Append(UnitListDictionary unitListDic)
        {
            if (unitListDic == null)
            {
                throw new ArgumentNullException("unitListDic");
            }

            if (unitListDic.UnitListMap == null)
            {
                string message =
                    Helper.NeutralFormat("The UnitListMap of unit list dictionary should not be null.");
                throw new ArgumentNullException("unitListDic", message);
            }

            if (unitListDic.UnitListMap.Keys == null)
            {
                string message =
                    Helper.NeutralFormat("The UnitListMap.Keys of unit list dictionary should not be null.");
                throw new ArgumentNullException("unitListDic", message);
            }

            foreach (string unitListKey in unitListDic.UnitListMap.Keys)
            {
                UnitList unitList = unitListDic.UnitListMap[unitListKey];
                if (!_unitListMap.ContainsKey(unitListKey))
                {
                    _unitListMap.Add(unitListKey, unitList);
                }
                else
                {
                    _unitListMap[unitListKey].Append(unitList);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Get original unit list used by ESP when speak the content.
        /// </summary>
        /// <param name="content">Content to be spoken.</param>
        /// <param name="waveUnits">Unit dictionary.</param>
        /// <returns>Unit list used by ESP to speak the content.</returns>
        public UnitListDictionary GetOriginalUnitList(string content, Dictionary<long, WaveUnit> waveUnits)
        {
            UnitListDictionary unitListDictionary = new UnitListDictionary();
            foreach (SP.TtsUtterance uttr in EspUtterances(content))
            {
                using (uttr)
                {
                    for (int index = 0; index < uttr.Segments.Count; index++)
                    {
                        WaveUnit waveUnit = waveUnits[uttr.Segments[index].InventoryWaveStartPosition];
                        UnitItem unitItem = new UnitItem();
                        unitItem.SentenceId = waveUnit.SentenceId;
                        unitItem.IndexInSentence = waveUnit.IndexInSentence;
                        unitItem.Name = waveUnit.Name;
                        unitListDictionary.AddUnit(_language, UnitList.UnitListType.Hold, unitItem);
                    }
                }
            }

            return unitListDictionary;
        }
コード例 #3
0
        /// <summary>
        /// Merge all unit list files.
        /// </summary>
        /// <param name="filePaths">File path array to be merged.</param>
        public void Merge(string[] filePaths)
        {
            if (filePaths == null)
            {
                throw new ArgumentNullException("filePaths");
            }

            foreach (string filePath in filePaths)
            {
                if (!File.Exists(filePath))
                {
                    throw Helper.CreateException(typeof(FileNotFoundException), filePath);
                }

                UnitListDictionary unitListDictionary = new UnitListDictionary();
                unitListDictionary.Load(filePath);
                Append(unitListDictionary);
            }
        }