Esempio n. 1
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            // check Speech API keys
            if (!string.IsNullOrEmpty(SettingsHelper.Instance.SpeechApiKey) && !string.IsNullOrEmpty(SettingsHelper.Instance.SpeechApiEndpoint))
            {
                this.speakButton.IsEnabled = true;
                this.apiRegion             = Regex.Replace(SettingsHelper.Instance.SpeechApiEndpoint, EndpointPattern, "$1");
                this.cacheDataFolder       = await ApplicationData.Current.LocalFolder.CreateFolderAsync("NeuralTTSDemo\\Cache", CreationCollisionOption.OpenIfExists);

                AvailableVoices.AddRange(NeuralTTSDataLoader.GetNeuralVoices());
                CachedResults.AddRange(await NeuralTTSDataLoader.GetCachedResults(cacheDataFolder));
            }
            else
            {
                this.speakButton.IsEnabled = false;
                ContentDialog missingApiKeyDialog = new ContentDialog
                {
                    Title             = "Missing Speech API Key",
                    Content           = "Please enter a valid Speech API key in the Settings Page.",
                    PrimaryButtonText = "Open Settings",
                    CloseButtonText   = "Close",
                    DefaultButton     = ContentDialogButton.Primary
                };

                ContentDialogResult result = await missingApiKeyDialog.ShowAsync();

                if (result == ContentDialogResult.Primary)
                {
                    AppShell.Current.NavigateToPage(typeof(SettingsPage));
                }
            }

            base.OnNavigatedTo(e);
        }
Esempio n. 2
0
        public BingTTSProvider()
        {
            Name          = "Bing Text To Speech";
            ProviderClass = Class.Web;
            HasVoices     = true;
            BackgroundWorker loadVoicesWorker = new BackgroundWorker();

            loadVoicesWorker.DoWork += delegate
            {
                List <CultureInfo> cultures = new List <CultureInfo>();
                cultures.AddRange(CultureInfo.GetCultures(CultureTypes.SpecificCultures));
                cultures.Sort((x, y) => x.DisplayName.CompareTo(y.DisplayName));
                AvailableVoices = cultures.Select(x => new Voice()
                {
                    Name = x.DisplayName + " (Male)", Language = x.Name, Gender = "male"
                }).ToList();
                AvailableVoices.AddRange(cultures.Select(x => new Voice()
                {
                    Name = x.DisplayName + " (Female)", Language = x.Name, Gender = "female"
                }).ToList());
                AvailableVoices.Sort((x, y) => x.Name.CompareTo(y.Name));
                SelectedVoice = AvailableVoices[0];
                if (Properties.Settings.Default.RememberLanguageSettings && this.Name == Properties.Settings.Default.LastTTSProvider)
                {
                    SelectedVoice = AvailableVoices.Find(n => n.Name == Properties.Settings.Default.LastTTSVoice);
                }
                else
                {
                    SelectedVoice = AvailableVoices[0];
                }
            };
            loadVoicesWorker.RunWorkerAsync();
        }
Esempio n. 3
0
 public AudioTrainerViewModel()
 {
     AvailableVoices.AddRange(_speechSynthesizer.GetInstalledVoices());
     SelectedVoice = AvailableVoices.FirstOrDefault();
 }