RecognizedWordUnit.Pronunciation Property

Returns the phonetic spelling of a recognized word.

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

Syntax

'Declaration
Public ReadOnly Property Pronunciation As String
public string Pronunciation { get; }
public:
property String^ Pronunciation {
    String^ get ();
}
/** @property */
public String get_Pronunciation ()
public function get Pronunciation () : String

Property Value

Returns an System.String containing a phonetic description of a word using the International Phonetic Alphabet (IPA).

Remarks

Many Unicode Windows-based fonts, such as Courier New, support displaying IPA strings. For more information on IPA, see International Phonetic Alphabet.

Example

The example below shows a utility routine (stringFromWordArray) that generates lexical (using LexicalForm), normalized (using P:Microsoft.Speech.Recognition.RecognizedWordUnit.Text), and a phonetic (using Pronunciation) text output (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 {
          Text,
          Normalized = Text,
          Lexical,
          Pronunciation
}

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;
      }

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

RecognizedWordUnit Class
RecognizedWordUnit Members
Microsoft.Speech.Recognition Namespace
DisplayAttributes Enumeration

Other Resources

International Phonetic Alphabet