Skip to content

Commit 82139f5

Browse files
Added check, in case coroutine was already running, to yeild break if called again.
1 parent 201c87e commit 82139f5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ public static int RecordingTime
126126

127127
private bool hasFailed;
128128

129+
private static bool isListening;
130+
129131
#region Unity Methods
130132

131133
protected override void Awake()
@@ -182,6 +184,10 @@ protected override void OnDestroy()
182184
/// </summary>
183185
public static IEnumerator StartRecording()
184186
{
187+
if (isListening) { yield break; }
188+
189+
isListening = true;
190+
185191
if (PhraseRecognitionSystem.Status == SpeechSystemStatus.Running)
186192
{
187193
PhraseRecognitionSystem.Shutdown();
@@ -209,13 +215,18 @@ public static IEnumerator StartRecording()
209215

210216
// Start recording from the microphone.
211217
dictationAudioClip = Microphone.Start(DeviceName, false, RecordingTime, samplingRate);
218+
212219
}
213220

214221
/// <summary>
215222
/// Ends the recording session.
216223
/// </summary>
217224
public static IEnumerator StopRecording()
218225
{
226+
if (!isListening) { yield break; }
227+
228+
isListening = false;
229+
219230
Microphone.End(DeviceName);
220231

221232
if (dictationRecognizer.Status == SpeechSystemStatus.Running)

0 commit comments

Comments
 (0)