RecognizedWordUnit.Text Property
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 normalized text for a recognized word.
public:
property System::String ^ Text { System::String ^ get(); };
public string Text { get; }
member this.Text : string
Public ReadOnly Property Text As String
A string that contains the normalized text output for a given input word.
The following example shows a utility routine that generates a string in one of three 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;
}
In most cases the values returned by Text and LexicalForm will be identical. However, recognition engines may use speech normalization to return more user-friendly or colloquial text representations of audio input.
Speech normalization 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.
Produk | Versi |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Umpan balik .NET
.NET adalah proyek sumber terbuka. Pilih tautan untuk memberikan umpan balik: