Danny
Danny

Reputation: 161

remove word from Text to Speech c#

I put the word to microsoft TTS And I wanted to ask is there a code to remove a word from the list.

to add word i use this

_recognizer.LoadGrammar(new Grammar(new GrammarBuilder("dog")));
_recognizer.LoadGrammar(new Grammar(new GrammarBuilder("cat")));
_recognizer.LoadGrammar(new Grammar(new GrammarBuilder("fish")));

Upvotes: 0

Views: 217

Answers (1)

You can use the UnloadGrammar() method.

You should probably keep a reference to the grammars though, so you can unload them easily.

Like this for example:

var grammar1 = new Grammar(new GrammarBuilder("dog"));
_recognizer.LoadGrammar(grammar1);

And to unload:

_recognizer.UnloadGrammar(grammar1);

You might be able to unload a grammar like this as well, not sure:

_recognizer.UnloadGrammar(new Grammar(new GrammarBuilder("dog")));

Documentation:

UnloadGrammar()

Upvotes: 1

Related Questions