Skip to content

Commit 1abbfc7

Browse files
committed
Added confidence level for the keyword recognizer in SpeechInputSource and assosiated editor script.
1 parent 1c99f53 commit 1abbfc7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Assets/HoloToolkit/Input/Scripts/Editor/SpeechInputSourceEditor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ public class SpeechInputSourceEditor : Editor
1111
{
1212
private SerializedProperty recognizerStart;
1313
private SerializedProperty keywordsAndKeys;
14+
private SerializedProperty confidenceLevel;
1415

1516
private void OnEnable()
1617
{
1718
recognizerStart = serializedObject.FindProperty("RecognizerStart");
19+
confidenceLevel = serializedObject.FindProperty("RecognitionConfidenceLevel");
1820
keywordsAndKeys = serializedObject.FindProperty("Keywords");
1921
}
2022

@@ -23,6 +25,7 @@ public override void OnInspectorGUI()
2325
serializedObject.Update();
2426
// the RecognizerStart field
2527
EditorGUILayout.PropertyField(recognizerStart);
28+
EditorGUILayout.PropertyField(confidenceLevel);
2629
// the Keywords field
2730
ShowList(keywordsAndKeys);
2831
serializedObject.ApplyModifiedProperties();

Assets/HoloToolkit/Input/Scripts/Voice/SpeechInputSource.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public enum RecognizerStartBehavior { AutoStart, ManualStart };
3939
[Tooltip("Whether the recognizer should be activated on start.")]
4040
public RecognizerStartBehavior RecognizerStart;
4141

42+
[Tooltip("The confidence level for the keyword recognizer.")]
43+
public ConfidenceLevel RecognitionConfidenceLevel;
44+
4245
[Tooltip("The keywords to be recognized and optional keyboard shortcuts.")]
4346
public KeywordAndKeyCode[] Keywords;
4447

@@ -59,8 +62,8 @@ protected override void Start()
5962
{
6063
keywords[index] = Keywords[index].Keyword;
6164
}
62-
63-
keywordRecognizer = new KeywordRecognizer(keywords);
65+
66+
keywordRecognizer = new KeywordRecognizer(keywords, RecognitionConfidenceLevel);
6467
keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
6568

6669
if (RecognizerStart == RecognizerStartBehavior.AutoStart)
@@ -114,7 +117,7 @@ private void ProcessKeyBindings()
114117
{
115118
if (Input.GetKeyDown(Keywords[index].KeyCode))
116119
{
117-
OnPhraseRecognized(ConfidenceLevel.High, TimeSpan.Zero, DateTime.Now, null, Keywords[index].Keyword);
120+
OnPhraseRecognized(RecognitionConfidenceLevel, TimeSpan.Zero, DateTime.Now, null, Keywords[index].Keyword);
118121
}
119122
}
120123
}

0 commit comments

Comments
 (0)