本文整理汇总了C#中SpeechRecognitionEngine.RequestRecognizerUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# SpeechRecognitionEngine.RequestRecognizerUpdate方法的具体用法?C# SpeechRecognitionEngine.RequestRecognizerUpdate怎么用?C# SpeechRecognitionEngine.RequestRecognizerUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpeechRecognitionEngine
的用法示例。
在下文中一共展示了SpeechRecognitionEngine.RequestRecognizerUpdate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button1_Click
private void button1_Click(object sender, EventArgs e)
{
_completed = new ManualResetEvent(false);
SpeechRecognitionEngine _recognizer = new SpeechRecognitionEngine();
_recognizer.RequestRecognizerUpdate(); // request for recognizer update
_recognizer.LoadGrammar(new Grammar(new GrammarBuilder("test"))); // load a grammar
_recognizer.RequestRecognizerUpdate(); // request for recognizer update
_recognizer.LoadGrammar(new Grammar(new GrammarBuilder("exit"))); // load a "exit" grammar
_recognizer.SpeechRecognized += _recognizer_SpeechRecognized;
_recognizer.SetInputToDefaultAudioDevice(); // set the input of the speech recognizer to the default audio device
_recognizer.RecognizeAsync(RecognizeMode.Multiple); // recognize speech asynchronous
_completed.WaitOne(); // wait until speech recognition is completed
_recognizer.Dispose(); // dispose the speech recognition engine
}
示例2: MainWindow
public MainWindow()
{
InitializeComponent();
var config = new JsonConfigHandler( System.IO.Path.Combine( Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData ), "LeagueTag" ) );
//config.Populate();
config.Save();
//config.Save(
return;
var engine = new SpeechRecognitionEngine();
var builder = new GrammarBuilder();
builder.Append( "tag" );
builder.Append( new Choices( "baron", "dragon" ) );
engine.RequestRecognizerUpdate();
engine.LoadGrammar( new Grammar( builder ) );
engine.SpeechRecognized += engine_SpeechRecognized;
engine.SetInputToDefaultAudioDevice();
engine.RecognizeAsync( RecognizeMode.Multiple );
CompositionTarget.Rendering += CompositionTarget_Rendering;
this.DataContext = this;
}
示例3: voiceChat
public SpeechRecognitionEngine recog; // Speech Recognition Engine. If it wasn't "Engine" it would use the windows implementation.
#endregion Fields
#region Constructors
public voiceChat(string locale)
{
InitializeComponent();
this.StartPosition = FormStartPosition.CenterScreen;
recog = new SpeechRecognitionEngine(new System.Globalization.CultureInfo(locale)); // Loads the localisation information.
recog.RequestRecognizerUpdate(); // Required to update the voice recognition.
recog.LoadGrammar(new Grammar(new GrammarBuilder("close voice chat")));
recog.LoadGrammar(new Grammar(new GrammarBuilder("clear chat")));
recog.LoadGrammar(new Grammar(new GrammarBuilder("send chat")));
recog.LoadGrammar(new DictationGrammar());
recog.SpeechDetected += recog_SpeechDetected; // Event when speech is detected. Not recgonized, just detected.
recog.SpeechRecognized += recog_SpeechRecognized; // Event when a word is found. Any processing is over there.
recog.SetInputToDefaultAudioDevice(); // This sets us to the default microphone set in the Windows audio panel.
recog.RecognizeAsync(RecognizeMode.Multiple); // This just makes voice recognition work beautifully. Just leave it alone.
}
示例4: button1_Click
private void button1_Click(object sender, EventArgs e)
{
SpeechSynthesizer sSynth = new SpeechSynthesizer();
PromptBuilder pBuilder = new PromptBuilder();
SpeechRecognitionEngine sRecognize = new SpeechRecognitionEngine();
Choices NumbersCh = new Choices();
for (int i = -999; i < 1000; i++)
{
NumbersCh.Add(i.ToString());
}
NumbersCh.Add("Times");
NumbersCh.Add("Multiply");
NumbersCh.Add("Divided");
NumbersCh.Add("Divide");
NumbersCh.Add("Plus");
NumbersCh.Add("Minus");
NumbersCh.Add("Add");
NumbersCh.Add("Subtract");
NumbersCh.Add("Power");
NumbersCh.Add("Left Over");
Choices OperatorCh = new Choices();
Grammar MathGr = new Grammar(new GrammarBuilder(NumbersCh));
Choices MainCh = new Choices();
MainCh.Add(new string[] { "Jack Hello" });
MainCh.Add(new string[] { "Jack Launch Chrome" });
MainCh.Add(new string[] { "Jack Go To My Facebook" });
MainCh.Add(new string[] { "Jack Launch Go" });
MainCh.Add(new string[] { "Jack Launch Rim World" });
MainCh.Add(new string[] { "Jack Launch Rust" });
MainCh.Add(new string[] { "Jack Launch Sins" });
MainCh.Add(new string[] { "Jack Launch K S P" });
MainCh.Add(new string[] { "Jack Launch Skype" });
MainCh.Add(new string[] { "Jack Launch Unity" });
MainCh.Add(new string[] { "Jack Wake Up" });
MainCh.Add(new string[] { "That will be all for now" });
MainCh.Add(new string[] { "Jack Close Window" });
MainCh.Add(new string[] { "Jack Save Progress" });
MainCh.Add(new string[] { "Alt Tab" });
MainCh.Add(new string[] { "Jack Tell A Joke" });
MainCh.Add(new string[] { "That Was A Good One Jack" });
MainCh.Add(new string[] { "Jack You Are Funny" });
MainCh.Add(new string[] { "Enter My Number" });
MainCh.Add(new string[] { "What Are My Numbers?" });
MainCh.Add(new string[] { "What Is My Answer?" });
MainCh.Add(new string[] { "Jack Lock" });
MainCh.Add(new string[] { "Jack Exit" });
Grammar MainGr = new Grammar(new GrammarBuilder(MainCh));
try
{
sRecognize.RequestRecognizerUpdate();
sRecognize.LoadGrammar(MainGr);
sRecognize.LoadGrammar(MathGr);
sRecognize.SpeechRecognized += sRecognize_SpeechRecognized;
sRecognize.SetInputToDefaultAudioDevice();
sRecognize.RecognizeAsync(RecognizeMode.Multiple);
sRecognize.Recognize();
}
catch
{
return;
}
}
示例5: createSpeechRecogntionEngine
private SpeechRecognitionEngine createSpeechRecogntionEngine(MainSystemTray form)
{
SpeechRecognitionEngine newSpeechRecognizer = new SpeechRecognitionEngine(CultureInfo.CurrentCulture);
//Setting up the grammars for the voice recognizer
Grammar commandGrammar = createCommandGrammar();
commandGrammar.Weight = 1f;
//"grammar:dictation#pronunciation"
Grammar dictationGrammar = new DictationGrammar("grammar:dictation");
dictationGrammar.Name = DictationState.GRAMMARNAME;
dictationGrammar.Weight = .3f;
//Setting up the voice recognizer to start listening for commands and send them to the SpeechRecognised method
newSpeechRecognizer.RequestRecognizerUpdate();
newSpeechRecognizer.LoadGrammar(commandGrammar);
newSpeechRecognizer.LoadGrammar(dictationGrammar);
try
{
newSpeechRecognizer.SetInputToDefaultAudioDevice();
newSpeechRecognizer.RecognizeAsync(RecognizeMode.Multiple);
}
catch (System.InvalidOperationException)
{
if (MessageBox.Show(
"You do not have an audio capture device installed \nPlease install a microphone and restart the program",
"No Capture Device", MessageBoxButtons.OK) == DialogResult.OK)
{
form.ExitProgram();
}
}
return newSpeechRecognizer;
}
示例6: game
private void game(int pos)
{
answerLabel.Text = null;
pointsLabel.Text = points.ToString();
sre = new SpeechRecognitionEngine();
Choices sList = new Choices();
String[] letters = getLetters(words[pos]);
//label1.Text = words[pos];
//label2.Text = pos.ToString();
jumbledWordLabel.Text = scrambleLetters(words[pos]);
wordPicBox.ImageLocation = "Class" + LoginForm.classSec + "_kidSpellImages/" + words[pos] + ".jpg";
this.wordPicBox.SizeMode = PictureBoxSizeMode.Zoom;
askQuestion(words[pos]);
sList.Add(letters);
Grammar gr = new Grammar(new GrammarBuilder(sList));
try
{
sre.RequestRecognizerUpdate();
sre.LoadGrammar(gr);
sre.SpeechRecognized += rec_SpeechRecognized;
sre.SetInputToDefaultAudioDevice();
sre.RecognizeAsync(RecognizeMode.Multiple);
}
catch (Exception)
{
throw;
}
}
示例7: button1_Click
public void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
button1.Text = "God Called";
label2.Text = "The god is listening...";
label2.ForeColor = Color.Red;
SpeechRecognitionEngine GodListener = new SpeechRecognitionEngine();
Choices GodList = new Choices();
GodList.Add(new string[] { "Make toast", "Make me toast", "Make me some toast", "Make me immortal", "Make rain", "call rain", "call the rain", "make it rain", "wink out of existence", "begone", "go now", "wink yourself out of existence" });
GrammarBuilder gb = new GrammarBuilder();
gb.Append(GodList);
Grammar GodGrammar = new Grammar(gb);
GodListener.MaxAlternates = 2;
try
{
GodListener.RequestRecognizerUpdate();
GodListener.LoadGrammar(GodGrammar);
GodListener.SetInputToDefaultAudioDevice();
GodListener.SpeechRecognized += GodListener_SpeechRecognized;
GodListener.AudioStateChanged += GodListener_AudioStateChanged;
GodListener.AudioLevelUpdated += GodListener_AudioLevelUpdated;
GodListener.RecognizeAsync(RecognizeMode.Multiple);
}
catch
{
return;
}
}
示例8: button1_Click
public void button1_Click(object sender, EventArgs e)
{
button1.Enabled = false;
button1.Text = "God Called";
label2.Text = "The god is listening...";
label2.ForeColor = Color.Red;
SpeechRecognitionEngine GodListener = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-UK"));
DictationGrammar GodGrammar = new DictationGrammar();
GodListener.MaxAlternates = 2;
try
{
GodListener.RequestRecognizerUpdate();
GodListener.LoadGrammar(GodGrammar);
GodListener.SetInputToDefaultAudioDevice();
GodListener.SpeechRecognized += GodListener_SpeechRecognized;
GodListener.AudioStateChanged += GodListener_AudioStateChanged;
GodListener.AudioLevelUpdated += GodListener_AudioLevelUpdated;
GodListener.RecognizeAsync(RecognizeMode.Multiple);
}
catch
{
return;
}
}
示例9: Form1
public Form1()
{
SpeechRecognitionEngine rec = new SpeechRecognitionEngine();
Choices list = new Choices();
list.Add(new String[] { "hello", "how are you" , "i'm fine" });
Grammar gr = new Grammar(new GrammarBuilder(list));
try
{
rec.RequestRecognizerUpdate();
rec.LoadGrammar(gr);
rec.SpeechRecognized += rec_SpeechRecognized;
rec.SetInputToDefaultAudioDevice();
rec.RecognizeAsync(RecognizeMode.Multiple);
}
catch { return; }
s.SelectVoiceByHints(VoiceGender.Female);
s.Speak("Hello , My name is VoiceBot");
InitializeComponent();
}