ReplacementText.DisplayAttributes 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得語音正規化程序所取代之文字的前置及尾端空格的相關資訊。
public:
property System::Speech::Recognition::DisplayAttributes DisplayAttributes { System::Speech::Recognition::DisplayAttributes get(); };
public System.Speech.Recognition.DisplayAttributes DisplayAttributes { get; }
member this.DisplayAttributes : System.Speech.Recognition.DisplayAttributes
Public ReadOnly Property DisplayAttributes As DisplayAttributes
屬性值
傳回 DisplayAttributes 物件,指定使用空白區來顯示正規化所取代的文字。
範例
下列範例會顯示辨識引擎所傳回物件之 RecognizedPhrase 使用者介面中的資訊。
internal static void DisplayBasicPhraseInfo(
Label label,
RecognizedPhrase result,
SpeechRecognizer rec)
{
if (result != null && label != null)
{
// Blank
if (rec != null)
{
// Clear
label.Text += String.Format(
" Recognizer currently at: {0} mSec\n" +
" Audio Device currently at: {1} mSec\n",
rec.RecognizerAudioPosition.TotalMilliseconds,
rec.AudioPosition.TotalMilliseconds);
}
if (result != null)
{ // Clear
RecognitionResult recResult = result as RecognitionResult;
if (recResult != null)
{
RecognizedAudio resultAudio = recResult.Audio;
if (resultAudio == null)
{
label.Text += String.Format(" Emulated input\n");
}
else
{
label.Text += String.Format(
" Candidate Phrase at: {0} mSec\n" +
" Phrase Length: {1} mSec\n" +
" Input State Time: {2}\n" +
" Input Format: {3}\n",
resultAudio.AudioPosition.TotalMilliseconds,
resultAudio.Duration.TotalMilliseconds,
resultAudio.StartTime.ToShortTimeString(),
resultAudio.Format.EncodingFormat.ToString());
}
}
label.Text += String.Format(" Confidence Level: {0}\n", result.Confidence);
if (result.Grammar != null)
{
label.Text += String.Format(
" Recognizing Grammar: {0}\n" +
" Recognizing Rule: {1}\n",
((result.Grammar.Name != null) ? (result.Grammar.Name) : "None"),
((result.Grammar.RuleName != null) ? (result.Grammar.RuleName) : "None"));
}
if (result.ReplacementWordUnits.Count != 0)
{
label.Text += String.Format(" Replacement text:\n");
foreach (ReplacementText rep in result.ReplacementWordUnits)
{
string repText = rep.Text;
// Add trailing spaces
if ((rep.DisplayAttributes & DisplayAttributes.OneTrailingSpace) != 0)
{
repText += " ";
}
if ((rep.DisplayAttributes & DisplayAttributes.TwoTrailingSpaces) != 0)
{
repText += " ";
}
if ((rep.DisplayAttributes & DisplayAttributes.ConsumeLeadingSpaces) != 0)
{
repText=repText.TrimStart();
}
if ((rep.DisplayAttributes & DisplayAttributes.ZeroTrailingSpaces) != 0)
{
repText = repText.TrimEnd();
}
label.Text += String.Format(
" At index {0} for {1} words. Text: \"{2}\"\n",
rep.FirstWordIndex, rep.CountOfWords, repText);
}
label.Text += String.Format("\n\n");
}
}
}
}