ReplacementText.FirstWordIndex 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 location of the first recognized word replaced by the speech normalization procedure.
public:
property int FirstWordIndex { int get(); };
public int FirstWordIndex { get; }
member this.FirstWordIndex : int
Public ReadOnly Property FirstWordIndex As Integer
Property Value
Returns the location of the first recognized word replaced by the speech normalization procedure.
Examples
In the following example, information about a RecognizedPhrase object returned by a recognition engine is displayed to a user interface.
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");
}
}
}
}
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET