public void Init(IModuleConfig config) { giftCacheManager = new GiftCacheManager(5); giftCacheManager.CacheExpired += GiftCacheManager_CacheExpired; speechProcessor = new SpeechProcessor(); speechProcessor.QueueChanged += Synthesizer_QueueChanged; DanmakuSpeechConfig speechConfig = (DanmakuSpeechConfig)config; OptionDict = speechConfig.OptionDict; SetVolume(speechConfig.Volume); Control = new DanmakuSpeechControl(this, speechConfig.OutputDevice); FileInfo fileInfo = new FileInfo("./config/speech.xml"); Stream speechConfigStream = null; try { if (fileInfo.Exists) { speechConfigStream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read, FileShare.Read); } else { speechConfigStream = Application.GetResourceStream(new Uri("Config/Speech.xml", UriKind.RelativeOrAbsolute)).Stream; } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(speechConfigStream); XmlNode enableAttr = xmlDocument.SelectSingleNode("speech/@enable"); string enable = enableAttr != null ? enableAttr.Value : "true"; if (enable.ToLower() != "false") { XmlNode tokenEndpointNode = xmlDocument.SelectSingleNode("speech/token_endpoint/text()"); XmlNode ttsEndpointNode = xmlDocument.SelectSingleNode("speech/tts_endpoint/text()"); XmlNode apiKeyNode = xmlDocument.SelectSingleNode("speech/api_key/text()"); string tokenEndpoint = tokenEndpointNode.Value; string ttsEndpoint = ttsEndpointNode.Value; string apiKey = apiKeyNode.Value; speechProcessor.Init(tokenEndpoint, ttsEndpoint, apiKey); } } catch (Exception ex) { Console.WriteLine(ex); } finally { if (speechConfigStream != null) { speechConfigStream.Close(); } } }
public void Init(IModuleConfig config) { giftCacheManager = new GiftCacheManager(5); DanmakuShowConfig displayConfig = (DanmakuShowConfig)config; OptionDict = displayConfig.OptionDict; Control = new DanmakuShowControl(this); DanmakuShowWindow displayWindow = new DanmakuShowWindow(); Window = displayWindow; if (displayConfig.WindowRect.Width != 0 && displayConfig.WindowRect.Height != 0) { displayWindow.Left = displayConfig.WindowRect.Left; displayWindow.Top = displayConfig.WindowRect.Top; displayWindow.Width = displayConfig.WindowRect.Width; displayWindow.Height = displayConfig.WindowRect.Height; } Window.Show(); Control.SetLock(displayConfig.IsLocked); }