This documentation is archived and is not being maintained.

RecognizedWordUnit Class

Provides the atomic unit of recognized speech.

Namespace: Microsoft.Speech.Recognition
Assembly: Microsoft.Speech (in microsoft.speech.dll)

[DebuggerDisplayAttribute("Text: {Text}")] 
public class RecognizedWordUnit
/** @attribute SerializableAttribute() */ 
/** @attribute DebuggerDisplayAttribute("Text: {Text}") */ 
public class RecognizedWordUnit
DebuggerDisplayAttribute("Text: {Text}") 
public class RecognizedWordUnit

All results returned by a recognition engine are constructed of RecognizedWordUnit objects.

An array of RecognizedWordUnit objects is accessible for any recognition operations through the Words property on the RecognizedPhrase object.

Addition to providing a measure of recognition certainty (Confidence) an instance of RecognizedWordUnit provides:

  • Normalized and exact (or lexical) text representations for a recognized word. For more information, see Text, and LexicalForm.

    Normalization of text from speech input is the use of special constructs or symbols to express speech in writing. For example, normalization can replace the spoken words "a dollar and sixteen cents" with "$1.16" in output text.
  • Pronunciation information using the International Phonetic Alphabet. For more information see Pronunciation and International .

  • Printing formatting. For more information see DisplayAttributes and DisplayAttributes.


The example below shows a utility routine (stringFromWordArray) that generates strings containing lexical output (using LexicalForm), normalized text (using Text), or a phonetic information in the International Phonetic Alphabet (using Pronunciation), formatted using DisplayAttributes objects obtained from the DisplayAttributes property, from the a System.Collections.ObjectModel.ReadOnlyCollection of RecognizedWordUnit objects, which is obtained from the P:Microsoft.Speech.Recognition.RecognizedPhrase.Words property on the RecognizedPhrase object.

internal enum WordType {
          Normalized = Text,
internal static string stringFromWordArray(ReadOnlyCollection<RecognizedWordUnit> words, WordType type) {
          string text = "";
          foreach (RecognizedWordUnit word in words) {
              string wordText = "";
              if (type == WordType.Text || type == WordType.Normalized) {
                  wordText = word.Text;
              } else if (type == WordType.Lexical) {
                  wordText = word.LexicalForm;
              } else if (type == WordType.Pronunciation) {
                  wordText = word.Pronunciation;
              } else {
                  throw new InvalidEnumArgumentException(String.Format("[0}: is not a valid input", type));
              //Use display attribute

              if ((word.DisplayAttributes & DisplayAttributes.OneTrailingSpace) != 0) {
                  wordText += " ";
              if ((word.DisplayAttributes & DisplayAttributes.TwoTrailingSpaces) != 0) {
                  wordText += "  ";
              if ((word.DisplayAttributes & DisplayAttributes.ConsumeLeadingSpaces) != 0) {
                  wordText = wordText.TrimStart();
              if ((word.DisplayAttributes & DisplayAttributes.ZeroTrailingSpaces) != 0) {
                  wordText = wordText.TrimEnd();

              text += wordText;

          return text;

All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.

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