次の方法で共有


Grammar.Weight プロパティ

定義

Grammar オブジェクトの重みの値を取得または設定します。

public:
 property float Weight { float get(); void set(float value); };
public float Weight { get; set; }
member this.Weight : single with get, set
Public Property Weight As Single

プロパティ値

Weight プロパティは、音声認識エンジン インスタンスが音声入力の処理時に文法に割り当てる必要がある相対的な重みを示す浮動小数点値を返します。 範囲は 0.0 から 1.0 までです。 既定値は 1.0 です。

次の例では、2 つの Grammar オブジェクトを作成します。1 つは数字用、1 つは分数用です。 Grammar オブジェクトには、名前と相対的な重みと優先順位が割り当てられ、インプロセス音声認識エンジンによって読み込まれます。 CreateDigitsGrammarCreateFractionsGrammar、およびrecognizer_SpeechRecognizedのメソッドはここには示されていません。

// Create a Grammar for recognizing numeric digits.
Grammar digitsGrammar = CreateDigitsGrammar();
digitsGrammar.Name = "Digits Grammar";
digitsGrammar.Priority = 2;
digitsGrammar.Weight = 0.6f;

// Create a Grammar for recognizing fractions.
Grammar fractionsGrammar = CreateFractionsGrammar();
fractionsGrammar.Name = "Fractions Grammar";
fractionsGrammar.Priority = 1;
fractionsGrammar.Weight = 1f;

// Create an in-process speech recognizer.
SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();

recognizer.SpeechRecognized +=
  new EventHandler<SpeechRecognizedEventArgs>(
    recognizer_SpeechRecognized);

// Load the digits and fractions Grammar objects.
recognizer.LoadGrammar(digitsGrammar);
recognizer.LoadGrammar(fractionsGrammar);

// Start recognition.
recognizer.SetInputToDefaultAudioDevice();
recognizer.RecognizeAsync(RecognizeMode.Multiple);

注釈

認識エンジンによる Weight の使用が複雑であるため、特定の文法のパフォーマンスへの影響は、 Priorityほど直接予測できません。

音声認識は重み付けシステムです。 文法の重み、文法内の代替候補に定義された重み、および音声モデルによって定義された確率の組み合わせに基づいて、可能なすべての認識パスが評価されます。 音声認識エンジンでは、これらの重みと確率の組み合わせを使用して、潜在的な代替認識をランク付けします。 重みが高い文法は、重みが低い文法よりも認識代替のランク付けに貢献します。

音声認識エンジンに対する Weight プロパティの効果は、認識エンジンの実装によって異なります。 Weightプロパティを使用して、アプリケーションの音声認識の精度を調整できますが、特定の認識環境の制御された診断調査の後、および使用中の認識エンジンに関する完全な情報を使用した場合にのみ使用する必要があります。

適用対象

こちらもご覧ください