ディクテーション文法は書き起こしのみを行うと思います。定義上、ディクテーション文法はすべての単語をサポートし、特定のセマンティック マッピングの手がかりがないため、セマンティックな意味を抽出せずに音声からテキストへの変換を行います。意味的な意味を抽出するには、カスタム文法を使用する必要があります。SRGS 文法を提供するか、コード内または SpeechServer ツールで構築する場合、特定の単語やフレーズのセマンティック マッピングを指定できます。その後、レコグナイザーは意味的な意味を抽出し、意味的な信頼を与えることができます。
認識時に認識エンジンから信頼値を取得できるはずです。System.Speech.Recognition.RecognitionResult.Confidence を試してください。
詳細については、Microsoft Server Speech Platform 10.2 SDK に付属のヘルプ ファイルを参照してください。(これは、サーバー アプリケーション用の Microsoft.Speech API であり、クライアント アプリケーション用の System.Speech API と非常によく似ています) (http://www.microsoft.com/downloads/en/details.aspx?FamilyID=1b1604d3-4f66 -4241-9a21-90a294a5c9a4.) または Microsoft.Speech のドキュメント ( http://msdn.microsoft.com/en-us/library/microsoft.speech.recognition.semanticvalue(v=office.13).aspx )
SemanticValue クラスの場合、次のように表示されます。
すべての Speech プラットフォーム ベースの認識エンジンの出力は、認識されたすべての出力に対して SemanticValue の有効なインスタンスを提供します。明示的な意味構造を持たないフレーズも含まれます。
フレーズの SemanticValue インスタンスは、RecogniizedPhrase オブジェクト (または RecognitionResult など、それを継承するオブジェクト) の Semantics プロパティを使用して取得されます。
セマンティック構造のない認識されたフレーズに対して取得された SemanticValue オブジェクトは、次の特徴があります。
子供がいない (カウントは 0)
Value プロパティが null です。
人為的信頼水準 1.0 (Confidence によって返される)
通常、アプリケーションは SemanticValue のインスタンスを間接的に作成し、Choices および GrammarBuilder オブジェクトと組み合わせて SemanticResultValue および SemanticResultKey インスタンスを使用して Grammar オブジェクトに追加します。
SemanticValue の直接構築は、厳密に型指定された文法の作成中に役立ちます
文法で SemanticValue 機能を使用する場合、通常、さまざまなフレーズを 1 つの意味にマッピングしようとします。あなたの場合、「IE」または「Internet Explorer」というフレーズは、両方とも同じセマンティックな意味にマップする必要があります。特定の意味にマッピングできる各フレーズを理解するために、文法に選択肢を設定します。簡単な Winform の例を次に示します。
private void btnTest_Click(object sender, EventArgs e)
{
SpeechRecognitionEngine myRecognizer = new SpeechRecognitionEngine();
Grammar testGrammar = CreateTestGrammar();
myRecognizer.LoadGrammar(testGrammar);
// use microphone
try
{
myRecognizer.SetInputToDefaultAudioDevice();
WriteTextOuput("");
RecognitionResult result = myRecognizer.Recognize();
string item = null;
float confidence = 0.0F;
if (result.Semantics.ContainsKey("item"))
{
item = result.Semantics["item"].Value.ToString();
confidence = result.Semantics["item"].Confidence;
WriteTextOuput(String.Format("Item is '{0}' with confidence {1}.", item, confidence));
}
}
catch (InvalidOperationException exception)
{
WriteTextOuput(String.Format("Could not recognize input from default aduio device. Is a microphone or sound card available?\r\n{0} - {1}.", exception.Source, exception.Message));
myRecognizer.UnloadAllGrammars();
}
}
private Grammar CreateTestGrammar()
{
// item
Choices item = new Choices();
SemanticResultValue itemSRV;
itemSRV = new SemanticResultValue("I E", "explorer");
item.Add(itemSRV);
itemSRV = new SemanticResultValue("explorer", "explorer");
item.Add(itemSRV);
itemSRV = new SemanticResultValue("firefox", "firefox");
item.Add(itemSRV);
itemSRV = new SemanticResultValue("mozilla", "firefox");
item.Add(itemSRV);
itemSRV = new SemanticResultValue("chrome", "chrome");
item.Add(itemSRV);
itemSRV = new SemanticResultValue("google chrome", "chrome");
item.Add(itemSRV);
SemanticResultKey itemSemKey = new SemanticResultKey("item", item);
//build the permutations of choices...
GrammarBuilder gb = new GrammarBuilder();
gb.Append(itemSemKey);
//now build the complete pattern...
GrammarBuilder itemRequest = new GrammarBuilder();
//pre-amble "[I'd like] a"
itemRequest.Append(new Choices("Can you open", "Open", "Please open"));
itemRequest.Append(gb, 0, 1);
Grammar TestGrammar = new Grammar(itemRequest);
return TestGrammar;
}