RecognizedWordUnit.Pronunciation Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the phonetic spelling of a recognized word.
public:
property System::String ^ Pronunciation { System::String ^ get(); };
public string Pronunciation { get; }
member this.Pronunciation : string
Public ReadOnly Property Pronunciation As String
Property Value
A string of characters from a supported phonetic alphabet, such as the International Phonetic Alphabet (IPA) or the Universal Phone Set (UPS).
Examples
The following example shows a utility routine that generates a string with one of three possible formats: lexical (using LexicalForm), normalized (using Text), and phonetic (using Pronunciation). The text output is obtained from a ReadOnlyCollection<T> of RecognizedWordUnit objects, which is obtained from the 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;
}
Remarks
The contents of Pronunciation indicate which pronunciation the speech recognition engine used to match speech input to one of its loaded Grammar objects. Pronunciations may be defined in the speech recognition engine's internal lexicon, in a lexicon document that is linked from a recognition grammar in a loaded Grammar object, or inline in a recognition grammar in a loaded Grammar object. A speech recognition engine may also create pronunciations for uncommon words whose pronunciations are not defined in a lexicon or grammar to which the speech recognition engine currently has access.
Many Windows-based Unicode fonts, such as Courier New, support the display of IPA strings. For more information, see International Phonetic Alphabet.
Applies to
See also
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈