Пример #1
0
 private void SetVoice(object sender)
 {
     // Determine if sender is VoiceInformation
     if (sender is VoiceInformation)
     {
         _speechSynthesizer.SetVoice((VoiceInformation)sender);
     }
     else
     { // If the sender is NOT VoiceInformation, it is a ListBox and cast its SelectedItem to VoiceInformation
         _speechSynthesizer.SetVoice((VoiceInformation)((ListBox)sender).SelectedItem);
     }
 }
Пример #2
0
        private async void SetVoiceFromCommand(string voice)
        {
            foreach (var voiceInformation in _availableVoices)
            {
                if (voiceInformation.DisplayName.Split(' ')[1].ToLower() == voice.ToLower())
                {
                    _speechSynthesizer.SetVoice(voiceInformation);
                    SelectedVoiceListBox.Text = voice;

                    break;
                }
            }
        }