Skip to content

Commit eb62dda

Browse files
Stephen HodgsonStephen Hodgson
authored andcommitted
Added DictationIputManagerEditor.
Moved Voice editor classes from Voice/Editor to Editor folder. Fixed wrong interface reference in DictationError raised event.
1 parent f4dbf42 commit eb62dda

11 files changed

+57
-27
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
4+
using UnityEditor;
5+
using UnityEngine;
6+
7+
namespace HoloToolkit.Unity.InputModule
8+
{
9+
[CustomEditor(typeof(DictationInputManager))]
10+
public class DictationInputManagerEditor : Editor
11+
{
12+
public override void OnInspectorGUI()
13+
{
14+
DictationInputManager.InitialSilenceTimeout = EditorGUILayout.Slider(new GUIContent("Initial Silence Timeout", "The default timeout with initial silence is 5 seconds."), DictationInputManager.InitialSilenceTimeout, 0.1f, 5f);
15+
DictationInputManager.AutoSilenceTimeout = EditorGUILayout.Slider(new GUIContent("Auto Silence Timeout", "The default timeout after a recognition is 20 seconds."), DictationInputManager.AutoSilenceTimeout, 5f, 60f);
16+
DictationInputManager.RecordingTime = EditorGUILayout.IntSlider(new GUIContent("Recording Time", "The default recording time is 10 seconds."), DictationInputManager.RecordingTime, 1, 60);
17+
}
18+
}
19+
}

Assets/HoloToolkit/Input/Scripts/Editor/DictationInputManagerEditor.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/HoloToolkit/Input/Scripts/Voice/Editor/KeywordAndKeyCodeDrawer.cs renamed to Assets/HoloToolkit/Input/Scripts/Editor/KeywordAndKeyCodeDrawer.cs

File renamed without changes.

Assets/HoloToolkit/Input/Scripts/Voice/Editor/KeywordAndKeyCodeDrawer.cs.meta renamed to Assets/HoloToolkit/Input/Scripts/Editor/KeywordAndKeyCodeDrawer.cs.meta

File renamed without changes.

Assets/HoloToolkit/Input/Scripts/Voice/Editor/SpeechInputHandlerEditor.cs renamed to Assets/HoloToolkit/Input/Scripts/Editor/SpeechInputHandlerEditor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public override void OnInspectorGUI()
3333
}
3434
else
3535
{
36-
SpeechInputHandler handler = target as SpeechInputHandler;
36+
SpeechInputHandler handler = (SpeechInputHandler)target;
3737
string duplicateKeyword = handler.keywords.GroupBy(keyword => keyword.Keyword.ToLower()).Where(group => group.Count() > 1).Select(group => group.Key).FirstOrDefault();
3838
if (duplicateKeyword != null)
3939
{
@@ -51,7 +51,7 @@ private void ShowList(SerializedProperty list)
5151
EditorGUI.indentLevel++;
5252

5353
// remove the keywords already assigned from the registered list
54-
SpeechInputHandler handler = target as SpeechInputHandler;
54+
SpeechInputHandler handler = (SpeechInputHandler)target;
5555
string[] availableKeywords = registeredKeywords.Except(handler.keywords.Select(keywordAndResponse => keywordAndResponse.Keyword)).ToArray();
5656

5757
// keyword rows
@@ -99,11 +99,11 @@ private void ShowList(SerializedProperty list)
9999
EditorGUI.indentLevel--;
100100
}
101101

102-
private IEnumerable<string> RegisteredKeywords()
102+
private static IEnumerable<string> RegisteredKeywords()
103103
{
104-
foreach(SpeechInputSource source in Object.FindObjectsOfType<SpeechInputSource>())
104+
foreach (SpeechInputSource source in FindObjectsOfType<SpeechInputSource>())
105105
{
106-
foreach(SpeechInputSource.KeywordAndKeyCode keywordAndKeyCode in source.Keywords)
106+
foreach (SpeechInputSource.KeywordAndKeyCode keywordAndKeyCode in source.Keywords)
107107
{
108108
yield return keywordAndKeyCode.Keyword;
109109
}

Assets/HoloToolkit/Input/Scripts/Voice/Editor/SpeechInputHandlerEditor.cs.meta renamed to Assets/HoloToolkit/Input/Scripts/Editor/SpeechInputHandlerEditor.cs.meta

File renamed without changes.

Assets/HoloToolkit/Input/Scripts/Voice/Editor/SpeechInputSourceEditor.cs renamed to Assets/HoloToolkit/Input/Scripts/Editor/SpeechInputSourceEditor.cs

File renamed without changes.

Assets/HoloToolkit/Input/Scripts/Voice/Editor/SpeechInputSourceEditor.cs.meta renamed to Assets/HoloToolkit/Input/Scripts/Editor/SpeechInputSourceEditor.cs.meta

File renamed without changes.

Assets/HoloToolkit/Input/Scripts/InputManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ public void RaiseDictationComplete(IInputSource source, uint sourceId, string di
712712
delegate (IDictationHandler handler, BaseEventData eventData)
713713
{
714714
DictationEventData casted = ExecuteEvents.ValidateEventData<DictationEventData>(eventData);
715-
handler.OnDictationComplete(casted);
715+
handler.OnDictationError(casted);
716716
};
717717

718718
public void RaiseDictationError(IInputSource source, uint sourceId, string dictationResult, AudioClip dictationAudioClip = null)

Assets/HoloToolkit/Input/Scripts/Microphone/DictationInputManager.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System;
55
using System.Text;
66
using UnityEngine;
7-
using UnityEngine.EventSystems;
87
using UnityEngine.Windows.Speech;
98

109
namespace HoloToolkit.Unity.InputModule
@@ -19,9 +18,6 @@ public class DictationInputManager : Singleton<DictationInputManager>, IInputSou
1918
/// Initial value for InitialSilenceTimeout.
2019
/// <remarks>Only used to initialize the DictationRecognizer's InitialSilenceTimeout value during Start.</remarks>
2120
/// </summary>
22-
[SerializeField]
23-
[Tooltip("The default timeout with initial silence is 5 seconds.")]
24-
[Range(0.1f, 30f)]
2521
private static float initialSilenceTimeout = 5f;
2622

2723
/// <summary>
@@ -50,9 +46,6 @@ public static float InitialSilenceTimeout
5046
/// Initial value for AutoSilenceTimeout.
5147
/// <remarks>Only used to initalize the DictationRecognizer's AutoSilenceTimeout value during Start.</remarks>
5248
/// </summary>
53-
[SerializeField]
54-
[Tooltip("The default timeout after a recognition is 20 seconds.")]
55-
[Range(5f, 60f)]
5649
private static float autoSilenceTimeout = 20f;
5750

5851
/// <summary>
@@ -79,13 +72,28 @@ public static float AutoSilenceTimeout
7972
}
8073

8174
/// <summary>
82-
/// Length in seconds for the manager to listen.
75+
/// Initial value for RecordingTime.
76+
/// <remarks>Only used to initalize the DictationRecognizer's RecordingTime value during Start.</remarks>
8377
/// </summary>
84-
[SerializeField]
85-
[Tooltip("Length in seconds for the manager to listen.")]
86-
[Range(1f, 60f)]
8778
private static int recordingTime = 10;
8879

80+
/// <summary>
81+
/// Length in seconds for the manager to listen.
82+
/// </summary>
83+
public static int RecordingTime
84+
{
85+
get
86+
{
87+
return recordingTime;
88+
}
89+
set
90+
{
91+
if (value <= 0) throw new ArgumentOutOfRangeException("value");
92+
93+
recordingTime = value;
94+
}
95+
}
96+
8997
/// <summary>
9098
/// Caches the text currently being displayed in dictation display text.
9199
/// </summary>
@@ -182,7 +190,7 @@ public static void StartRecording()
182190
recordingStarted = true;
183191

184192
// Start recording from the microphone.
185-
dictationAudioClip = Microphone.Start(DeviceName, false, recordingTime, samplingRate);
193+
dictationAudioClip = Microphone.Start(DeviceName, false, RecordingTime, samplingRate);
186194
}
187195

188196
/// <summary>

0 commit comments

Comments
 (0)