예제 #1
0
        /// <summary>
        /// Prepare voice font used by test.
        /// </summary>
        /// <param name="outputDir">Voice font output dir.</param>
        /// <returns>Font version information.</returns>
        public static FontVersion PrepareVoiceFontEnUSSamantha(string outputDir)
        {
            Helper.EnsureFolderExist(outputDir);
            string samanthaDataSite = Path.Combine(Helper.FindTestDataPath(), @"en-US\Samantha\DataFiles");
            FontVersion fontVersion = new FontVersion("M1033SVR", WaveCompressCatalog.Unc,
                Offline.Waveform.WaveFormatTag.Mulaw, 8000, 1);

            Collection<FontVersion> fontVersions = new Collection<FontVersion>();
            fontVersions.Add(fontVersion);

            string unitUnitTable = Localor.GetLanguageDataFile(Language.EnUS, Localor.UnitTableFileName);
            string phoneUnitTable = Path.Combine(Helper.FindTestDataPath(),
                @"en-US\Samantha\DataFiles\Meta\PhoneUnitTable.xml");
            Localor.SetLanguageDataFile(Language.EnUS, Localor.UnitTableFileName, phoneUnitTable);

            PrepareVoiceFont(Language.EnUS, string.Empty, string.Empty, null, fontVersions,
                Path.Combine(samanthaDataSite, @"Script\Script.txt"), Path.Combine(samanthaDataSite, @"Alignment\PhoneSegment"),
                Path.Combine(samanthaDataSite, @"Speech\Wave16k"), Path.Combine(samanthaDataSite, @"Speech\Wave16kFiltered"),
                string.Empty, Path.Combine(samanthaDataSite, @"Speech\Epoch"), outputDir);

            if (string.IsNullOrEmpty(unitUnitTable))
            {
                Localor.ClearLanguageDataFile(Language.EnUS, Localor.UnitTableFileName);
            }
            else
            {
                Localor.SetLanguageDataFile(Language.EnUS, Localor.UnitTableFileName, unitUnitTable);
            }

            return fontVersion;
        }
예제 #2
0
        /// <summary>
        /// Prepare voice font used by test.
        /// </summary>
        /// <param name="outputDir">Voice font output dir.</param>
        /// <returns>Font version information.</returns>
        public static FontVersion PrepareVoiceFontEnUSTom(string outputDir)
        {
            Helper.EnsureFolderExist(outputDir);
            string tomDataSite = Path.Combine(Helper.FindTestDataPath(), @"en-US\Tom\DataFiles");
            FontVersion fontVersion = new FontVersion("M1033SVR", WaveCompressCatalog.Unc,
                Offline.Waveform.WaveFormatTag.Mulaw, 8000, 1);

            Collection<FontVersion> fontVersions = new Collection<FontVersion>();
            fontVersions.Add(fontVersion);

            PrepareVoiceFont(Language.EnUS, string.Empty, string.Empty, null, fontVersions,
                Path.Combine(tomDataSite, "Script.txt"), Path.Combine(tomDataSite, "Segment"),
                Path.Combine(tomDataSite, "Wave16k"), Path.Combine(tomDataSite, "Wave16kFiltered"),
                string.Empty,
                Path.Combine(tomDataSite, "Epoch"), outputDir);
            return fontVersion;
        }
        /// <summary>
        /// Parse version node list.
        /// </summary>
        /// <param name="versionsNodeList">Versions node list.</param>
        /// <param name="nsmgr">Xml namespace manager.</param>
        /// <param name="versions">Version collection.</param>
        public static void ParseVersions(XmlNodeList versionsNodeList,
            XmlNamespaceManager nsmgr, Collection<FontVersion> versions)
        {
            if (versionsNodeList == null)
            {
                throw new ArgumentNullException("versionsNodeList");
            }

            if (nsmgr == null)
            {
                throw new ArgumentNullException("nsmgr");
            }

            if (versions == null)
            {
                throw new ArgumentNullException("versions");
            }

            versions.Clear();
            foreach (XmlNode node in versionsNodeList)
            {
                XmlElement ele = (XmlElement)node;
                FontVersion fv = new FontVersion();

                fv.CompressCatalog = (WaveCompressCatalog)Enum.Parse(typeof(WaveCompressCatalog),
                    ele.GetAttribute("compress"));
                fv.PcmCategory = (WaveFormatTag)Enum.Parse(typeof(WaveFormatTag),
                    ele.GetAttribute("encoding"));
                fv.SamplesPerSecond = int.Parse(ele.GetAttribute("samplesPerSecond"),
                    CultureInfo.InvariantCulture);
                fv.BytesPerSample = int.Parse(ele.GetAttribute("bytesPerSample"),
                    CultureInfo.InvariantCulture);
                fv.Name = ele.GetAttribute("name");

                try
                {
                    fv.Validate();
                }
                catch (NotSupportedException nse)
                {
                    string message = string.Format(CultureInfo.InvariantCulture,
                        "Not support version config found {0}.",
                        ele.OuterXml);
                    throw new InvalidDataException(message, nse);
                }

                versions.Add(fv);
            }
        }