internal static NarratorVocalization Create(MediaElement mediaElement, string language) { var vocalization = new NarratorVocalization(mediaElement); vocalization.Initialize(language); return(vocalization); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var passedEnvironment = e.Parameter as IWriterEnvironment; var environment = passedEnvironment ?? new UwpWriterEnvironment(); _model = new ApplicationModel(environment); ((INotifyPropertyChanged)_model.Environment.Settings).PropertyChanged += (s, ee) => _model.RefreshSuggestionsView(); TheHost.Model = _model; _demo = ApplicationDemo.Create(this); var vocalizer = NarratorVocalization.Create(TheMediaElement, "en"); _ = Narrator.AttachNarrator(_model, vocalizer); if (e.Parameter == null) { _model.Environment.Settings.SpeakWordByWord = false; _model.Environment.Settings.SpeakWordByWord = false; _model.Environment.Settings.FindFollowOnPredictions = false; _model.Environment.Settings.CombineCorePredictions = false; _model.Environment.Settings.FindCorePredictionPrefixes = false; _model.Environment.Settings.FindCorePredictionSuffixes = false; } else if (passedEnvironment == null) { IsEnabled = false; try { var values = ApplicationData.Current.LocalSettings.Values; foreach (WriterSettingName name in Enum.GetValues(typeof(WriterSettingName))) { var ob = values[name.ToString()]; if (ob != null) { var value = (bool)ob; _model.Environment.Settings.Set(name, value); } } ((INotifyPropertyChanged)_model.Environment.Settings).PropertyChanged += (s, ee) => { if (ee.PropertyName != null && Enum.TryParse <WriterSettingName>(ee.PropertyName, out var name)) { var value = _model.Environment.Settings.Get(name); values[name.ToString()] = value; } }; await _model.LoadUtterancesAsync(); } finally { IsEnabled = true; } } Model = _model; }