Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to disable speech plugin from python #213

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions FreePIE.Core.Plugins/SpeechPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class SpeechPlugin : Plugin
private SpeechRecognitionEngine recognitionEngine;
private Dictionary<string, RecognitionInfo> recognizerResults;

private bool recognitionActive = true;

public override object CreateGlobal()
{
Expand All @@ -34,6 +35,11 @@ public override void Stop()
}
}

public void EnableRecognition(bool enable)
{
recognitionActive = enable;
}

public void SelectVoice(string name)
{
EnsureSynthesizer();
Expand Down Expand Up @@ -87,10 +93,14 @@ private bool EnsureRecognizer()

recognitionEngine.SpeechRecognized += (s, e) =>
{
var info = recognizerResults[e.Result.Text];

if (e.Result.Confidence >= info.Confidence)
info.Result = true;
if (recognitionActive)
{
var info = recognizerResults[e.Result.Text];

if (e.Result.Confidence >= info.Confidence)
info.Result = true;
}

};

}
Expand Down Expand Up @@ -158,5 +168,10 @@ public void selectVoice(string name)
{
plugin.SelectVoice(name);
}

public void enableRecognition(bool enable)
{
plugin.EnableRecognition(enable);
}
}
}