/// <summary> /// Initializes a new instance of the ScriptSynthesizer class. /// </summary> /// <param name="serviceProvider">Service provider.</param> /// <param name="commonConfig">Common config of script synthesizer.</param> /// <param name="scriptFeatureImportConfig">Config of script feature import.</param> /// <param name="customizedFeaturePluginManager">Plugin manager of customized feature extraction.</param> public ScriptSynthesizer(ServiceProvider serviceProvider, ScriptSynthesizerCommonConfig commonConfig, ScriptFeatureImportConfig scriptFeatureImportConfig, CustomizedFeaturePluginManager customizedFeaturePluginManager) { if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } // commonConfig can be null. // scriptFeatureImportConfig can be null. // customizedFeaturePluginManager can be null. _serviceProvider = serviceProvider; _scriptFeatureImportConfig = scriptFeatureImportConfig; if (commonConfig != null) { _logger = new TextLogger(commonConfig.TraceLogFile); _logger.Reset(); } if (_scriptFeatureImportConfig != null) { _scriptFeatureImport = new ScriptFeatureImport(commonConfig, _scriptFeatureImportConfig, _serviceProvider, _logger); } if (customizedFeaturePluginManager != null) { _customizedFeatureExtraction = new CustomizedFeatureExtraction(_serviceProvider, customizedFeaturePluginManager); } }
/// <summary> /// Check consistency of script and utterance. /// </summary> /// <param name="utt">Tts utterance.</param> /// <param name="scriptSentence">Script sentence.</param> /// <param name="option">Checking option.</param> private static void CheckConsistency(SP.TtsUtterance utt, ScriptSentence scriptSentence, ScriptFeatureImportConfig.CheckingOptions option) { if ((option & ScriptFeatureImportConfig.CheckingOptions.Word) == ScriptFeatureImportConfig.CheckingOptions.Word) { CheckWordConsistency(utt, scriptSentence); } }
/// <summary> /// Initializes a new instance of the ScriptFeatureImport class. /// </summary> /// <param name="commonConfig">Common config of script synthesizer.</param> /// <param name="config">Config of script feature import.</param> /// <param name="serviceProvider">Service provider.</param> /// <param name="logger">Log writer.</param> public ScriptFeatureImport(ScriptSynthesizerCommonConfig commonConfig, ScriptFeatureImportConfig config, ServiceProvider serviceProvider, TextLogger logger) { //// commonConfig can be null. if (config == null) { throw new ArgumentNullException("config"); } if (serviceProvider == null) { throw new ArgumentNullException("serviceProvider"); } _commonConfig = commonConfig; _config = config; if (_config.UpdateSilenceWord && _config.UpdateFixedSilenceDuration) { throw new InvalidDataException("Cannot implement updating script silence word and fixed silence duration together."); } if (!_config.UpdateSilenceWord && _config.UpdateScriptSilenceDuration) { throw new InvalidDataException("Cannot update script silence duration without update silence word."); } _serviceProvider = serviceProvider; if (_config.UpdateSilenceWord || _config.UpdateFixedSilenceDuration) { UpdateSilenceDurationsConfig(); } _logger = logger; _serviceProvider.Engine.LinguisticProsodyTagger.Processing += new EventHandler<TtsModuleEventArgs>(OnLinguisticProcessing); _serviceProvider.Engine.LinguisticProsodyTagger.Processed += new EventHandler<TtsModuleEventArgs>(OnLinguisticProcessed); _serviceProvider.Engine.Processed += new EventHandler<TtsModuleEventArgs>(OnProcessed); _serviceProvider.Engine.AcousticProsodyTagger.Processed += new EventHandler<TtsModuleEventArgs>(OnAcousticProcessed); if (_commonConfig != null) { Helper.EnsureFolderExist(_commonConfig.OutputWaveDir); } }
/// <summary> /// Parse config snippet and create the config object. /// </summary> /// <param name="nsmgr">Namespace manager.</param> /// <param name="configNode">Xml node containing the config.</param> /// <returns>The config object.</returns> public static ScriptFeatureImportConfig ParseConfig(XmlNamespaceManager nsmgr, XmlNode configNode) { ScriptFeatureImportConfig scriptFeatureImportConfig = null; if (nsmgr != null && configNode != null) { scriptFeatureImportConfig = new ScriptFeatureImportConfig(); scriptFeatureImportConfig.Load(nsmgr, configNode); } return scriptFeatureImportConfig; }