Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Speech List Box for C# (SAPI 5.3)

Speech API 5.3

Microsoft Speech API 5.3

Speech List Box for C#


Speech List Box for C# is an elementary application showcasing speech recognition (SR) and dynamic grammars.

In general, a grammar is the set of words that the engine can recognize. In the case of dictation, all words are in the grammar and no limitation is imposed on the user. In the case of command and control applications, the list of words is much more restricted. For example, a grammar containing commands to operate a menu system, might include less than a dozen words, each word corresponding to a menu or menu item. Often, this list of words is generated ahead of time and represents a static or fixed grammar. However, dynamic grammars allow users to add words while running the application. This permits users to customize the grammar according to their needs. The list box sample demonstrated making and maintaining a dynamic grammar.


To compile Speech List Box for C#, Visual Studio.NET and specifically Visual Studio C#.NET is required. Speech List Box for C# is actually two projects compiled at the same time. The one file is the application itself and the other is a control component for the display area. By running ListboxSample.sln, the control component is actually loaded and registered in the computer as one step.

The easiest way to compile them is a batch build. Open ListboxSample.sln. For a standard SAPI SDK 5.3 installation this C:\Program Files\Microsoft Speech SDK 5.3\Samples\CSharp\Listbox\ListBoxCSharp.sln. Once loaded, compile the the solution by selecting Build->Batch Build. In the subsequent dialog select the Build checkbox for Debug if you need the debugging symbols in the project or the Release checkbox if not. Then click build to compile. Both projects build together and then display the list box dialog.

The samples are installed as Locked files. To modify them, they must be unlocked. To unlock, right-click the file or files, select Properties, and clear the Read-Only check box.

Using Speech List Box for C#

Speech List Box for C# opens with no words in the dynamic grammar. You can add words or phrases by typing the text in the edit box and clicking Add. After adding at least one item, individual items may be highlighted by saying, "select" followed by the text of the item. For example, if one of the items a list of cities were "Seattle," saying "Select Seattle" will choose the Seattle item.


Use Add to move the text in the edit box to the display area. The text can be either a single word or a phrase.


Use Remove to remove the selected item(s) in the display area from the dynamic grammar. Highlight the item to be removed.

Speech Enabled

Use Speech Enabled to enable the speech recognizer. By default it is on and the speech engine will attempt to recognize voice commands. Disabling this option prohibits recognition attempts. Regardless of the recognizer state, if no items have been added to the display area, no recognition will occur.


Click the close box in the title bar to exit Speech List Box for C#.

© 2015 Microsoft