SpeechRecognitionRejectedEventArgs 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
提供 SpeechRecognitionRejected 與 SpeechRecognitionRejected 事件的資訊。
public ref class SpeechRecognitionRejectedEventArgs : System::Speech::Recognition::RecognitionEventArgs
public class SpeechRecognitionRejectedEventArgs : System.Speech.Recognition.RecognitionEventArgs
[System.Serializable]
public class SpeechRecognitionRejectedEventArgs : System.Speech.Recognition.RecognitionEventArgs
type SpeechRecognitionRejectedEventArgs = class
inherit RecognitionEventArgs
[<System.Serializable>]
type SpeechRecognitionRejectedEventArgs = class
inherit RecognitionEventArgs
Public Class SpeechRecognitionRejectedEventArgs
Inherits RecognitionEventArgs
- 繼承
- 屬性
範例
下列範例會辨識「在音樂類別中顯示藝人清單」或「顯示相簿」等片語。 此範例會使用 事件的處理常式 SpeechRecognitionRejected ,在語音輸入無法與文法內容相符時,在主控台中顯示通知,且有足夠的信心來產生成功的辨識。
using System;
using System.Speech.Recognition;
namespace SampleRecognition
{
class Program
{
static void Main(string[] args)
// Initialize a shared speech recognition engine.
{
using (SpeechRecognizer recognizer =
new SpeechRecognizer())
{
// Create a grammar.
// Create lists of alternative choices.
Choices listTypes = new Choices(new string[] { "albums", "artists" });
Choices genres = new Choices(new string[] {
"blues", "classical", "gospel", "jazz", "rock" });
// Create a GrammarBuilder object and assemble the grammar components.
GrammarBuilder mediaMenu = new GrammarBuilder("Display");
mediaMenu.Append("the list of", 0, 1);
mediaMenu.Append(listTypes);
mediaMenu.Append("in the", 0, 1);
mediaMenu.Append(genres);
mediaMenu.Append("category", 0, 1);
// Build a Grammar object from the GrammarBuilder.
Grammar mediaMenuGrammar = new Grammar(mediaMenu);
mediaMenuGrammar.Name = "Media Chooser";
// Attach event handlers.
recognizer.LoadGrammarCompleted +=
new EventHandler<LoadGrammarCompletedEventArgs>(recognizer_LoadGrammarCompleted);
recognizer.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
recognizer.SpeechRecognitionRejected +=
new EventHandler<SpeechRecognitionRejectedEventArgs>(recognizer_SpeechRecognitionRejected);
// Load the grammar object to the recognizer.
recognizer.LoadGrammarAsync(mediaMenuGrammar);
// Keep the console window open.
Console.ReadLine();
}
}
// Handle the SpeechRecognitionRejected event.
static void recognizer_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e)
{
Console.WriteLine("Speech input was rejected.");
foreach (RecognizedPhrase phrase in e.Result.Alternates)
{
Console.WriteLine(" Rejected phrase: " + phrase.Text);
Console.WriteLine(" Confidence score: " + phrase.Confidence);
}
}
// Handle the LoadGrammarCompleted event.
static void recognizer_LoadGrammarCompleted(object sender, LoadGrammarCompletedEventArgs e)
{
Console.WriteLine("Grammar loaded: " + e.Grammar.Name);
}
// Handle the SpeechRecognized event.
static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
Console.WriteLine("Speech recognized: " + e.Result.Text);
}
}
}
備註
事件 SpeechRecognitionRejected
是由 SpeechRecognizer 和 SpeechRecognitionEngine 類別引發。
當辨識作業中沒有任何替代專案具有足以接受的信賴分數時,語音辨識引擎會產生SpeechRecognitionRejected事件。 可透過 Result 屬性取得拒絕片語的詳細資訊。
SpeechRecognitionRejectedEventArgs 衍生自 RecognitionEventArgs 。
屬性
Result |
取得與語音辨識事件關聯的辨識結果資料。 (繼承來源 RecognitionEventArgs) |
方法
Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
GetHashCode() |
做為預設雜湊函式。 (繼承來源 Object) |
GetType() |
取得目前執行個體的 Type。 (繼承來源 Object) |
MemberwiseClone() |
建立目前 Object 的淺層複製。 (繼承來源 Object) |
ToString() |
傳回代表目前物件的字串。 (繼承來源 Object) |