示例#1
0
        /// <summary>
        /// Calculate the target cost.
        /// </summary>
        /// <param name="featureId">Feature id.</param>
        /// <param name="src">Source.</param>
        /// <param name="target">Target.</param>
        /// <returns>Cost.</returns>
        private float CalcTargetCost(TtsFeature featureId, int src, int target)
        {
            float cost = 0;
            if (_targetCosts.ContainsKey(featureId))
            {
                cost = _targetCosts[featureId][src][target];
            }

            return cost;
        }
示例#2
0
        /// <summary>
        /// Get target cost table.
        /// </summary>
        /// <param name="featureId">Feature id.</param>
        /// <returns>Target cost table.</returns>
        private float[][] GetTargetCost(TtsFeature featureId)
        {
            float[][] costTable = null;
            if (_targetCosts.ContainsKey(featureId))
            {
                costTable = _targetCosts[featureId];
            }

            return costTable;
        }
示例#3
0
        /// <summary>
        /// Set target cost table.
        /// </summary>
        /// <param name="featureId">Feature id.</param>
        /// <param name="costTable">Target cost table.</param>
        private void SetTargetCost(TtsFeature featureId, float[][] costTable)
        {
            if (costTable == null)
            {
                throw new ArgumentNullException("costTable");
            }

            if (_targetCosts.ContainsKey(featureId))
            {
                _targetCosts[featureId] = costTable;
            }
            else
            {
                _targetCosts.Add(featureId, costTable);
            }
        }
示例#4
0
        /// <summary>
        /// Filter the Ids question file into a feature-specified question file.
        /// </summary>
        /// <param name="sourceFile">Source file.</param>
        /// <param name="targetFile">Target file after filtered.</param>
        /// <param name="feature">Feature used to filter.</param>
        public static void FilterQuestion(string sourceFile,
            string targetFile, TtsFeature feature)
        {
            Helper.EnsureFolderExistForFile(targetFile);
            using (StreamWriter sw = new StreamWriter(targetFile))
            using (StreamReader sr = new StreamReader(sourceFile))
            {
                string line = null;
                while ((line = sr.ReadLine()) != null)
                {
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }

                    string[] items = line.Split(new char[] { ' ' },
                        StringSplitOptions.RemoveEmptyEntries);

                    TtsFeature currentFeature =
                        (TtsFeature)int.Parse(items[1], CultureInfo.InvariantCulture);

                    if (currentFeature == feature)
                    {
                        sw.WriteLine(line);
                    }
                }
            }
        }