The SemanticValue is primary object implementing the Speech platform semantic technology. Semantic interpretation allows grammars to define, and recognition engines to correctly interpret, audio input but organized into more easily processable information, not just as words and sequences of words.
For example, the recognition engine output "Change background to red" would have to be parsed and interpreted by an application before it could be acted upon.
However, a Grammar object can specify an semantic interpretation to make processing clearer.
In the case of the phrase "Change background to red", the Grammar could specify that the phrase has two semantic substructures, one for selecting background or foreground (represented by the text "background"), the other for selecting color (represented by the text "red").
This semantic interpretation by the recognition engine is expressed in a tree of SemanticValue objects.
SemanticValue implements of the System.Collection.Generic.IDictionary, System.Collections.Generic.ICollection and System.Collections.Generic.IEnumerable interfaces.
Under Speech platform, the semantics of a recognition operation are represented in a tree of SemanticValue objects.
Each SemanticValue instance has
A [System.Object]type, accessed using the Value property, used to key the instance of the SemanticValue.
A measure of accuracy returned by the Confidence property
A collection name value pairs (System.Collections.Generic.KeyValuePair) of child objects, which are also SemanticValue instances. Child nodes are accessible through the SemanticValue implementation of System.Collection.Generic.IDictionary using with a string lookup key and a SemanticValue instance, for example:
foreach (KeyValuePair<String, SemanticValue> child in semantics) {
Utils.CreateSemanticsTreeNodes(semanticsNode.Nodes, child.Value, child.Key);
}
All Speech platform-based recognition engines output provide valid instances of SemanticValue for all recognized output, even phrases with no explicit semantic structure.
The SemanticValue instance for a phrase is obtained using the Semantics property on the RecognizedPhrase object (or objects which inherirt from it, such as RecognitionResult).
SemanticValue object obtained for recognized phrases without semantic structure are characterized by:
Having no children (Count is 0)
The Value property is nullNothingnullptra null reference (Nothing in Visual Basic).
An artificial confidence level of 1.0 (returned by Confidence)
Typically, applications create instance of SemanticValue indirectly, adding them to Grammar objects by using SemanticResultValue, and SemanticResultKey instances in conjunction with, Choices and GrammarBuilder objects.
Director construction of an SemanticValue is useful during the creation of strongly typed grammars.