Språk

RecognizedWordUnit.Pronunciation Egenskap

Definition

Hämtar den fonetiska stavningen av ett känt ord.

public:
 property System::String ^ Pronunciation { System::String ^ get(); };
public string? Pronunciation { get; }
public string Pronunciation { get; }
member this.Pronunciation : string
Public ReadOnly Property Pronunciation As String

Egenskapsvärde

En sträng med tecken från ett fonetikalbet som stöds, till exempel IPA (International Phonetic Alphabet) eller Universal Phone Set (UPS).

Exempel

I följande exempel visas en verktygsrutin som genererar en sträng med något av tre möjliga format: lexikal (med ), LexicalFormnormaliserad (med ) Textoch fonetik (med ).Pronunciation Textutdata hämtas från en ReadOnlyCollection<T> av RecognizedWordUnit objekten, som hämtas från Words egenskapen på RecognizedPhrase objektet.

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

Kommentarer

Innehållet i Pronunciation anger vilket uttal taligenkänningsmotorn använde för att matcha talindata till ett av dess inlästa Grammar objekt. Uttal kan definieras i taligenkänningsmotorns interna lexikon, i ett lexikondokument som är länkat från en igenkännings grammatik i ett inläst objekt eller infogat Grammar i en igenkännings grammatik i ett inläst Grammar objekt. En taligenkänningsmotor kan också skapa uttal för ovanliga ord vars uttal inte definieras i ett lexikon eller grammatik som taligenkänningsmotorn för närvarande har åtkomst till.

Många Windows-baserade Unicode-teckensnitt, till exempel Courier New, stöder visning av IPA-strängar. Mer information finns i International Phonetic Alphabet.

Gäller för

Se även