Skip to content

Commit d7fdb3b

Browse files
author
Joost van Schaik
committed
Works around a DicationRecognizer.StopRecording() issue. This https://issuetracker.unity3d.com/issues/wsa-windows-speech-dictationrecognizer-throws-assertion-failed-on-expression-succeeded-hr-when-user-cancels-the-input claims it is fixed, but it is clearly not.
1 parent b9a6b26 commit d7fdb3b

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ protected override void OnDestroy()
101101

102102
#endregion // Unity Methods
103103

104+
104105
/// <summary>
105106
/// Turns on the dictation recognizer and begins recording audio from the default microphone.
106107
/// </summary>
@@ -167,6 +168,14 @@ public static IEnumerator StartRecording(GameObject listener = null, float initi
167168
/// </summary>
168169
public static IEnumerator StopRecording()
169170
{
171+
yield return Instance.StopRecordingInternal();
172+
}
173+
174+
/// <summary>
175+
/// Ends the recording session.
176+
/// </summary>
177+
private IEnumerator StopRecordingInternal()
178+
{
170179
#if UNITY_WSA || UNITY_STANDALONE_WIN
171180
if (!IsListening || isTransitioning)
172181
{
@@ -190,16 +199,21 @@ public static IEnumerator StopRecording()
190199
dictationRecognizer.Stop();
191200
}
192201

202+
StartCoroutine(FinishStopRecording());
203+
#else
204+
return null;
205+
#endif
206+
}
207+
208+
private IEnumerator FinishStopRecording()
209+
{
193210
while (dictationRecognizer.Status == SpeechSystemStatus.Running)
194211
{
195212
yield return null;
196213
}
197214

198215
PhraseRecognitionSystem.Restart();
199216
isTransitioning = false;
200-
#else
201-
return null;
202-
#endif
203217
}
204218

205219
#region Dictation Recognizer Callbacks

0 commit comments

Comments
 (0)