Skip to content

Commit

Permalink
System.NullReferenceException: Referencia a objeto no establecida com…
Browse files Browse the repository at this point in the history
…o instancia de un objeto.

   en System.Speech.Internal.Synthesis.VoiceSynthesis.BuildInstalledVoices(VoiceSynthesis voiceSynthesizer)
   en System.Speech.Internal.Synthesis.VoiceSynthesis..ctor(WeakReference speechSynthesizer)
   en System.Speech.Synthesis.SpeechSynthesizer.get_VoiceSynthesizer()
   en MixItUp.WPF.Services.WindowsSpeechService.GetVoices() en S:\Code\mixer-mixitup\MixItUp.WPF\Services\WindowsSpeechService.cs:línea 33
   en MixItUp.Base.ViewModel.Actions.TextToSpeechActionEditorControlViewModel.UpdateTextToSpeechProvider()
   en MixItUp.Base.ViewModel.Actions.TextToSpeechActionEditorControlViewModel..ctor(TextToSpeechActionModel action)
   en MixItUp.Base.ViewModel.Actions.ActionEditorListControlViewModel.<AddAction>d__22.MoveNext()
  • Loading branch information
Matthew Olivo committed Oct 23, 2024
1 parent 3c986d9 commit 6f1c7c4
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions MixItUp.WPF/Services/WindowsSpeechService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,21 @@ public IEnumerable<TextToSpeechVoice> GetVoices()
{
List<TextToSpeechVoice> voices = new List<TextToSpeechVoice>();

SpeechSynthesizer synthesizer = new SpeechSynthesizer();
foreach (InstalledVoice voice in synthesizer.GetInstalledVoices())
try
{
if (voice.Enabled)
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
foreach (InstalledVoice voice in synthesizer.GetInstalledVoices())
{
voices.Add(new TextToSpeechVoice(voice.VoiceInfo.Name));
if (voice.Enabled)
{
voices.Add(new TextToSpeechVoice(voice.VoiceInfo.Name));
}
}
}
catch (Exception ex)
{
Logger.Log(ex);
}

return voices;
}
Expand Down

0 comments on commit 6f1c7c4

Please sign in to comment.