Skip to content

Commit 7486ca5

Browse files
Reverted isRunning and fixed logic with recordingStarted bool.
1 parent 82139f5 commit 7486ca5

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

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

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ public static int RecordingTime
108108
private static int samplingRate;
109109

110110
/// <summary>
111-
/// Use this to reset the UI once the Mic is done recording.
111+
/// Is the Dictation Manager currently running?
112112
/// </summary>
113-
private static bool recordingStarted;
113+
public static bool IsListening { get; private set; }
114114

115115
/// <summary>
116116
/// String result of the current dictation.
@@ -126,8 +126,6 @@ public static int RecordingTime
126126

127127
private bool hasFailed;
128128

129-
private static bool isListening;
130-
131129
#region Unity Methods
132130

133131
protected override void Awake()
@@ -148,17 +146,12 @@ protected override void Awake()
148146

149147
// Use this string to cache the text currently displayed.
150148
textSoFar = new StringBuilder();
151-
152-
// Use this to reset once the Microphone is done recording after it was started.
153-
recordingStarted = false;
154149
}
155150

156151
private void Update()
157152
{
158-
if (recordingStarted && !Microphone.IsRecording(DeviceName) && dictationRecognizer.Status == SpeechSystemStatus.Running)
153+
if (IsListening && !Microphone.IsRecording(DeviceName) && dictationRecognizer.Status == SpeechSystemStatus.Running)
159154
{
160-
recordingStarted = false;
161-
162155
// If the microphone stops as a result of timing out, make sure to manually stop the dictation recognizer.
163156
StartCoroutine(StopRecording());
164157
}
@@ -184,9 +177,9 @@ protected override void OnDestroy()
184177
/// </summary>
185178
public static IEnumerator StartRecording()
186179
{
187-
if (isListening) { yield break; }
180+
if (IsListening) { yield break; }
188181

189-
isListening = true;
182+
IsListening = true;
190183

191184
if (PhraseRecognitionSystem.Status == SpeechSystemStatus.Running)
192185
{
@@ -211,8 +204,6 @@ public static IEnumerator StartRecording()
211204
yield return null;
212205
}
213206

214-
recordingStarted = true;
215-
216207
// Start recording from the microphone.
217208
dictationAudioClip = Microphone.Start(DeviceName, false, RecordingTime, samplingRate);
218209

@@ -223,9 +214,9 @@ public static IEnumerator StartRecording()
223214
/// </summary>
224215
public static IEnumerator StopRecording()
225216
{
226-
if (!isListening) { yield break; }
217+
if (!IsListening) { yield break; }
227218

228-
isListening = false;
219+
IsListening = false;
229220

230221
Microphone.End(DeviceName);
231222

0 commit comments

Comments
 (0)