static void Main(string[] args) { SpeechSynthesizer synth = new SpeechSynthesizer(); synth.Speak("bruh moment"); synth.Dispose(); Console.ReadKey(); }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { if (synthesizer != null) { while (synthesizer.State == SynthesizerState.Speaking) { Thread.Sleep(100); } synthesizer.Dispose(); } } disposedValue = true; } }
public void stopSpeech() { speechSynthesizer.Dispose(); createSynthesizer(); SpeakString = null; }