SrgsText Class
Represents the Text content for the World Wide Web Consortium (W3C) Speech Recognition Grammar Specification (SRGS) elements.
Namespace: Microsoft.Speech.Recognition.SrgsGrammar
Assembly: Microsoft.Speech (in microsoft.speech.dll)
Syntax
'Declaration
<SerializableAttribute> _
<DebuggerDisplayAttribute("{DebuggerDisplayString ()}")> _
Public NotInheritable Class SrgsText
Inherits SrgsElement
[SerializableAttribute]
[DebuggerDisplayAttribute("{DebuggerDisplayString ()}")]
public sealed class SrgsText : SrgsElement
[SerializableAttribute]
[DebuggerDisplayAttribute(L"{DebuggerDisplayString ()}")]
public ref class SrgsText sealed : public SrgsElement
/** @attribute SerializableAttribute() */
/** @attribute DebuggerDisplayAttribute("{DebuggerDisplayString ()}") */
public final class SrgsText extends SrgsElement
SerializableAttribute
DebuggerDisplayAttribute("{DebuggerDisplayString ()}")
public final class SrgsText extends SrgsElement
Remarks
The text content is the text found within a set of SRGS element tags.
Inheritance Hierarchy
System.Object
System.MarshalByRefObject
Microsoft.Speech.Recognition.SrgsGrammar.SrgsElement
Microsoft.Speech.Recognition.SrgsGrammar.SrgsText
Example
In the following example, the SRGS XML one-of element is created by the C# code that follows. Small, Medium and Large are the Text contents of the corresponding item elements in the XML code fragment.
When the SrgsItem object is constructed with a System.String parameter, a SrgsText object is created with its Text property initialized to the value of that parameter. The SrgsItem object is then added to the Elements collection on the SrgsItem object. The following C# example shows how the Text property on the original SrgsItem objects can be changed to the values shown in the XML fragment.
<!-- SRGS XML Fragment -->
<one-of>
<item>Small</item>
<item>Medium</item>
<item>Large</item>
</one-of>
//C# fragment
SrgsDocument document = new SrgsDocument();
SrgsItem smallItem = new SrgsItem("Large");
SrgsItem mediumItem = new SrgsItem("Larger");
SrgsItem largeItem = new SrgsItem("Largest");
SrgsText textOfItem = null;
if (smallItem.Elements[0] is SrgsText)
{
textOfItem = smallItem.Elements[0] as SrgsText;
textOfItem.Text = "Small";
}
if (mediumItem.Elements[0] is SrgsText)
{
textOfItem = mediumItem.Elements[0] as SrgsText;
textOfItem.Text = "Medium";
}
if (largeItem.Elements[0] is SrgsText)
{
textOfItem = largeItem.Elements[0] as SrgsText;
textOfItem.Text = "Large";
}
SrgsOneOf oneOf = new SrgsOneOf(smallItem, mediumItem, largeItem);
SrgsRule rule = new SrgsRule("Sizes", oneOf);
document.Rules.Add(rule);
document.Root = rule;
string srgsDocumentFile = Path.Combine(Path.GetTempPath(), "srgsDocumentFile.xml");
XmlWriter writer = XmlWriter.Create(srgsDocumentFile);
document.WriteSrgs(writer);
writer.Close();
Thread Safety
All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.
Platforms
Development Platforms
Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition
Target Platforms
See Also
Reference
SrgsText Members
Microsoft.Speech.Recognition.SrgsGrammar Namespace
SrgsItem Class