RecognizerUpdateReachedEventArgs クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
RecognizerUpdateReached または RecognizerUpdateReached イベントからのデータを返します。
public ref class RecognizerUpdateReachedEventArgs : EventArgs
public class RecognizerUpdateReachedEventArgs : EventArgs
type RecognizerUpdateReachedEventArgs = class
inherit EventArgs
Public Class RecognizerUpdateReachedEventArgs
Inherits EventArgs
- 継承
例
次の例は、オブジェクトの読み込みとアンロードを行うコンソールアプリケーションを示して Grammar います。 アプリケーションでは、メソッドを使用して RequestRecognizerUpdate 音声認識エンジンが一時停止するように要求し、更新プログラムを受信できるようにします。 その後、アプリケーションはオブジェクトを読み込んだりアンロードしたりし Grammar ます。
各更新時に、イベントのハンドラーによって、 SpeechRecognitionEngine.RecognizerUpdateReached 現在読み込まれているオブジェクトの名前と状態が Grammar コンソールに書き込まれます。 文法が読み込まれてアンロードされると、アプリケーションは最初にファームの動物の名前、次にファームの動物の名前と果物の名前を認識し、次に果物の名前のみを認識します。
using System;
using System.Speech.Recognition;
using System.Collections.Generic;
using System.Threading;
namespace SampleRecognition
{
class Program
{
private static SpeechRecognitionEngine recognizer;
public static void Main(string[] args)
{
// Initialize an in-process speech recognition engine and configure its input.
using (recognizer = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US")))
{
recognizer.SetInputToDefaultAudioDevice();
// Create the first grammar - Farm.
Choices animals = new Choices(new string[] { "cow", "pig", "goat" });
GrammarBuilder farm = new GrammarBuilder(animals);
Grammar farmAnimals = new Grammar(farm);
farmAnimals.Name = "Farm";
// Create the second grammar - Fruit.
Choices fruit = new Choices(new string[] { "apples", "peaches", "oranges" });
GrammarBuilder favorite = new GrammarBuilder(fruit);
Grammar favoriteFruit = new Grammar(favorite);
favoriteFruit.Name = "Fruit";
// Attach event handlers.
recognizer.SpeechRecognized +=
new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
recognizer.RecognizerUpdateReached +=
new EventHandler<RecognizerUpdateReachedEventArgs>(recognizer_RecognizerUpdateReached);
recognizer.SpeechRecognitionRejected +=
new EventHandler<SpeechRecognitionRejectedEventArgs>(recognizer_SpeechRecognitionRejected);
// Load the Farm grammar.
recognizer.LoadGrammar(farmAnimals);
// Start asynchronous, continuous recognition.
recognizer.RecognizeAsync(RecognizeMode.Multiple);
Console.WriteLine("Starting asynchronous, continuous recognition");
Console.WriteLine(" Farm grammar is loaded and enabled.");
// Pause to recognize farm animals.
Thread.Sleep(7000);
Console.WriteLine();
// Request an update and load the Fruit grammar.
recognizer.RequestRecognizerUpdate();
recognizer.LoadGrammarAsync(favoriteFruit);
Thread.Sleep(7000);
// Request an update and unload the Farm grammar.
recognizer.RequestRecognizerUpdate();
recognizer.UnloadGrammar(farmAnimals);
Thread.Sleep(7000);
}
// Keep the console window open.
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
// At the update, get the names and enabled status of the currently loaded grammars.
public static void recognizer_RecognizerUpdateReached(
object sender, RecognizerUpdateReachedEventArgs e)
{
Console.WriteLine();
Console.WriteLine("Update reached:");
Thread.Sleep(1000);
string qualifier;
List<Grammar> grammars = new List<Grammar>(recognizer.Grammars);
foreach (Grammar g in grammars)
{
qualifier = (g.Enabled) ? "enabled" : "disabled";
Console.WriteLine(" {0} grammar is loaded and {1}.",
g.Name, qualifier);
}
}
// Write the text of the recognized phrase to the console.
static void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
Console.WriteLine(" Speech recognized: " + e.Result.Text);
}
// Write a message to the console when recognition fails.
static void recognizer_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e)
{
Console.WriteLine(" Recognition attempt failed");
}
}
}
注釈
RecognizerUpdateReached イベントは、音声認識エンジンを一時停止して、文法の読み込みやアンロードなどのアトミックおよび同期的な変更を適用するためのメカニズムを提供します。
アプリケーションがインスタンスを使用して認識を管理している場合は、 SpeechRecognitionEngine いずれかのメソッドを使用して、 SpeechRecognitionEngine.RequestRecognizerUpdate エンジンが更新プログラムを受信するのを一時停止するように要求できます。 インスタンスは、 SpeechRecognitionEngine SpeechRecognitionEngine.RecognizerUpdateReached 更新の準備ができたときにイベントを発生させます。
SpeechRecognitionEngineインスタンスが一時停止されている間に、オブジェクトの読み込み、アンロード、有効化、および無効化を行ったり、 Grammar 、、の各プロパティの値を変更したりでき BabbleTimeout InitialSilenceTimeout EndSilenceTimeout ます。
アプリケーションがインスタンスを使用して認識を管理している場合は、 SpeechRecognizer いずれかのメソッドを使用して、 SpeechRecognizer.RequestRecognizerUpdate エンジンが更新プログラムを受信するのを一時停止するように要求できます。 インスタンスは、 SpeechRecognizer SpeechRecognizer.RecognizerUpdateReached 更新の準備ができたときにイベントを発生させます。
SpeechRecognizerインスタンスが一時停止されている間は、オブジェクトの読み込み、アンロード、有効化、および無効化を行うことができ Grammar ます。
イベントとイベントを処理するとき SpeechRecognitionEngine.RecognizerUpdateReached SpeechRecognizer.RecognizerUpdateReached 、認識エンジンは、イベントハンドラーが戻るまで一時停止します。
RecognizerUpdateReachedEventArgs は、EventArgs から派生します。
プロパティ
| AudioPosition |
イベントに関連付けられているオーディオの位置を取得します。 |
| UserToken |
アプリケーションが RequestRecognizerUpdate または RequestRecognizerUpdate を呼び出すときにシステムに渡される |
メソッド
| Equals(Object) |
指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。 (継承元 Object) |
| GetHashCode() |
既定のハッシュ関数として機能します。 (継承元 Object) |
| GetType() |
現在のインスタンスの Type を取得します。 (継承元 Object) |
| MemberwiseClone() |
現在の Object の簡易コピーを作成します。 (継承元 Object) |
| ToString() |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |