Skip to content

Commit 59a2ffc

Browse files
author
Lukas Tönne
authored
Catch Unity exception in speech input provider. (#4054)
* Catch Unity exception in speech input provider. This is necessary so other providers can still be enabled after the speech input provider fails. * Change error message to bring it in line with the dication provider.
1 parent cf79a80 commit 59a2ffc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Assets/MixedRealityToolkit.Providers/WindowsVoiceInput/WindowsSpeechInputProvider.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,17 @@ public override void Enable()
9292

9393
if (keywordRecognizer == null)
9494
{
95-
keywordRecognizer = new KeywordRecognizer(newKeywords, (ConfidenceLevel)RecognitionConfidenceLevel);
95+
try
96+
{
97+
keywordRecognizer = new KeywordRecognizer(newKeywords, (ConfidenceLevel)RecognitionConfidenceLevel);
98+
}
99+
catch (UnityException ex)
100+
{
101+
Debug.LogError($"Failed to start keyword recognizer. Are microphone permissions granted? Exception: {ex}");
102+
keywordRecognizer = null;
103+
return;
104+
}
105+
96106
keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
97107
}
98108

0 commit comments

Comments
 (0)