Skip to content

Commit ebfe2f6

Browse files
Merge pull request #2737 from wassx/mrtk_development
Fix conditionals and zero parameter constructor to fix linux standalo…
2 parents 60e6a6f + f66378b commit ebfe2f6

File tree

6 files changed

+25
-41
lines changed

6 files changed

+25
-41
lines changed

Assets/MixedRealityToolkit-SDK/Features/Input/MixedRealityInputManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,10 +1618,10 @@ public void RaiseManipulationCanceled(IMixedRealityInputSource source, Handednes
16181618
};
16191619

16201620
/// <inheritdoc />
1621-
public void RaiseSpeechCommandRecognized(IMixedRealityInputSource source, MixedRealityInputAction inputAction, UnityEngine.Windows.Speech.ConfidenceLevel confidence, TimeSpan phraseDuration, DateTime phraseStartTime, UnityEngine.Windows.Speech.SemanticMeaning[] semanticMeanings, string text)
1621+
public void RaiseSpeechCommandRecognized(IMixedRealityInputSource source, MixedRealityInputAction inputAction, RecognitionConfidenceLevel confidence, TimeSpan phraseDuration, DateTime phraseStartTime, string text)
16221622
{
16231623
// Create input event
1624-
speechEventData.Initialize(source, inputAction, confidence, phraseDuration, phraseStartTime, semanticMeanings, text);
1624+
speechEventData.Initialize(source, inputAction, confidence, phraseDuration, phraseStartTime, text);
16251625

16261626
// Pass handler through HandleEvent to perform modal/fallback logic
16271627
HandleEvent(speechEventData, OnSpeechKeywordRecognizedEventHandler);

Assets/MixedRealityToolkit/InputSystem/Sources/BaseGenericInputSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,4 @@ public virtual void Dispose() { }
9595

9696
#endregion IEquality Implementation
9797
}
98-
}
98+
}

Assets/MixedRealityToolkit/_Core/Devices/VoiceInput/WindowsDictationInputDeviceManager.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
namespace Microsoft.MixedReality.Toolkit.Core.Devices.VoiceInput
1616
{
17+
#if UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
1718
public class WindowsDictationInputDeviceManager : BaseDeviceManager, IMixedRealityDictationManager
1819
{
1920
/// <summary>
@@ -28,8 +29,6 @@ public WindowsDictationInputDeviceManager(string name, uint priority) : base(nam
2829
/// </summary>
2930
public bool IsListening { get; private set; } = false;
3031

31-
private DictationRecognizer dictationRecognizer;
32-
3332
private bool hasFailed;
3433
private bool hasListener;
3534
private bool isTransitioning;
@@ -59,8 +58,8 @@ public WindowsDictationInputDeviceManager(string name, uint priority) : base(nam
5958
/// </summary>
6059
private AudioClip dictationAudioClip;
6160

62-
#if UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
63-
61+
private DictationRecognizer dictationRecognizer;
62+
6463
/// <inheritdoc />
6564
public override void Enable()
6665
{
@@ -219,7 +218,6 @@ public async Task<AudioClip> StopRecordingAsync()
219218
await new WaitUntil(() => PhraseRecognitionSystem.Status == SpeechSystemStatus.Running);
220219

221220
isTransitioning = false;
222-
223221
return dictationAudioClip;
224222
}
225223

@@ -282,7 +280,6 @@ private void DictationRecognizer_DictationError(string error, int hresult)
282280
textSoFar = null;
283281
dictationResult = string.Empty;
284282
}
285-
286-
#endif // UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
287283
}
284+
#endif // UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
288285
}

Assets/MixedRealityToolkit/_Core/Devices/VoiceInput/WindowsSpeechInputDeviceManager.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.MixedReality.Toolkit.Core.Interfaces.InputSystem;
88
using Microsoft.MixedReality.Toolkit.Core.Managers;
99
using System;
10+
using System.Collections.Generic;
1011
using UnityEngine;
1112

1213
#if UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
@@ -15,6 +16,7 @@
1516

1617
namespace Microsoft.MixedReality.Toolkit.Core.Devices.VoiceInput
1718
{
19+
#if UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
1820
public class WindowsSpeechInputDeviceManager : BaseDeviceManager, IMixedRealitySpeechSystem
1921
{
2022
public WindowsSpeechInputDeviceManager(string name, uint priority) : base(name, priority) { }
@@ -29,11 +31,10 @@ public WindowsSpeechInputDeviceManager(string name, uint priority) : base(name,
2931
/// </summary>
3032
public IMixedRealityInputSource InputSource = null;
3133

32-
#if UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
3334

3435
private KeywordRecognizer keywordRecognizer;
3536

36-
public ConfidenceLevel RecognitionConfidenceLevel { get; set; }
37+
public RecognitionConfidenceLevel RecognitionConfidenceLevel { get; set; }
3738

3839
/// <inheritdoc />
3940
public override void Enable()
@@ -49,8 +50,8 @@ public override void Enable()
4950
newKeywords[i] = Commands[i].Keyword;
5051
}
5152

52-
RecognitionConfidenceLevel = (ConfidenceLevel)MixedRealityManager.Instance.ActiveProfile.InputSystemProfile.SpeechCommandsProfile.SpeechRecognitionConfidenceLevel;
53-
keywordRecognizer = new KeywordRecognizer(newKeywords, RecognitionConfidenceLevel);
53+
RecognitionConfidenceLevel = MixedRealityManager.Instance.ActiveProfile.InputSystemProfile.SpeechCommandsProfile.SpeechRecognitionConfidenceLevel;
54+
keywordRecognizer = new KeywordRecognizer(newKeywords, (ConfidenceLevel) RecognitionConfidenceLevel);
5455
keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
5556

5657
if (MixedRealityManager.Instance.ActiveProfile.InputSystemProfile.SpeechCommandsProfile.SpeechRecognizerStartBehavior == AutoStartBehavior.AutoStart)
@@ -68,7 +69,7 @@ public override void Update()
6869
{
6970
if (Input.GetKeyDown(Commands[i].KeyCode))
7071
{
71-
OnPhraseRecognized(RecognitionConfidenceLevel, TimeSpan.Zero, DateTime.Now, null, Commands[i].Keyword);
72+
OnPhraseRecognized((ConfidenceLevel) RecognitionConfidenceLevel, TimeSpan.Zero, DateTime.Now, Commands[i].Keyword);
7273
}
7374
}
7475
}
@@ -111,21 +112,20 @@ public void StopRecognition()
111112

112113
private void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)
113114
{
114-
OnPhraseRecognized(args.confidence, args.phraseDuration, args.phraseStartTime, args.semanticMeanings, args.text);
115+
OnPhraseRecognized(args.confidence, args.phraseDuration, args.phraseStartTime, args.text);
115116
}
116117

117-
private void OnPhraseRecognized(ConfidenceLevel confidence, TimeSpan phraseDuration, DateTime phraseStartTime, SemanticMeaning[] semanticMeanings, string text)
118+
private void OnPhraseRecognized(ConfidenceLevel confidence, TimeSpan phraseDuration, DateTime phraseStartTime, string text)
118119
{
119120
for (int i = 0; i < Commands?.Length; i++)
120121
{
121122
if (Commands[i].Keyword == text)
122123
{
123-
InputSystem.RaiseSpeechCommandRecognized(InputSource, Commands[i].Action, confidence, phraseDuration, phraseStartTime, semanticMeanings, text);
124+
InputSystem.RaiseSpeechCommandRecognized(InputSource, Commands[i].Action, (RecognitionConfidenceLevel)confidence, phraseDuration, phraseStartTime, text);
124125
break;
125126
}
126127
}
127128
}
128-
129-
#endif // UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
130129
}
130+
#endif // UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
131131
}
Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using Microsoft.MixedReality.Toolkit.Core.Definitions.InputSystem;
5+
using Microsoft.MixedReality.Toolkit.Core.Definitions.Utilities;
56
using Microsoft.MixedReality.Toolkit.Core.Interfaces.InputSystem;
67
using System;
78
using UnityEngine.EventSystems;
89

9-
#if UNITY_WSA || UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
10-
using UnityEngine.Windows.Speech;
11-
#endif
12-
1310
namespace Microsoft.MixedReality.Toolkit.Core.EventDatum.Input
1411
{
1512
/// <summary>
@@ -32,20 +29,14 @@ public class SpeechEventData : BaseInputEventData
3229
/// </summary>
3330
public string RecognizedText { get; private set; }
3431

35-
/// <inheritdoc />
36-
public SpeechEventData(EventSystem eventSystem) : base(eventSystem) { }
37-
38-
#if UNITY_WSA || UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
39-
4032
/// <summary>
4133
/// A measure of correct recognition certainty.
4234
/// </summary>
43-
public ConfidenceLevel Confidence { get; private set; }
35+
public RecognitionConfidenceLevel Confidence { get; private set; }
36+
37+
/// <inheritdoc />
38+
public SpeechEventData(EventSystem eventSystem) : base(eventSystem) { }
4439

45-
/// <summary>
46-
/// A semantic meaning of recognized phrase.
47-
/// </summary>
48-
public SemanticMeaning[] SemanticMeanings { get; private set; }
4940

5041
/// <summary>
5142
/// Populates the event with data.
@@ -55,17 +46,14 @@ public SpeechEventData(EventSystem eventSystem) : base(eventSystem) { }
5546
/// <param name="confidence"></param>
5647
/// <param name="phraseDuration"></param>
5748
/// <param name="phraseStartTime"></param>
58-
/// <param name="semanticMeanings"></param>
5949
/// <param name="recognizedText"></param>
60-
public void Initialize(IMixedRealityInputSource inputSource, MixedRealityInputAction inputAction, ConfidenceLevel confidence, TimeSpan phraseDuration, DateTime phraseStartTime, SemanticMeaning[] semanticMeanings, string recognizedText)
50+
public void Initialize(IMixedRealityInputSource inputSource, MixedRealityInputAction inputAction, RecognitionConfidenceLevel confidence, TimeSpan phraseDuration, DateTime phraseStartTime, string recognizedText)
6151
{
6252
BaseInitialize(inputSource, inputAction);
6353
Confidence = confidence;
6454
PhraseDuration = phraseDuration;
6555
PhraseStartTime = phraseStartTime;
66-
SemanticMeanings = semanticMeanings;
6756
RecognizedText = recognizedText;
6857
}
69-
#endif
7058
}
7159
}

Assets/MixedRealityToolkit/_Core/Interfaces/InputSystem/IMixedRealityInputSystem.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,9 +716,8 @@ public interface IMixedRealityInputSystem : IMixedRealityEventSystem
716716
/// <param name="confidence"></param>
717717
/// <param name="phraseDuration"></param>
718718
/// <param name="phraseStartTime"></param>
719-
/// <param name="semanticMeanings"></param>
720719
/// <param name="text"></param>
721-
void RaiseSpeechCommandRecognized(IMixedRealityInputSource source, MixedRealityInputAction inputAction, UnityEngine.Windows.Speech.ConfidenceLevel confidence, TimeSpan phraseDuration, DateTime phraseStartTime, UnityEngine.Windows.Speech.SemanticMeaning[] semanticMeanings, string text);
720+
void RaiseSpeechCommandRecognized(IMixedRealityInputSource source, MixedRealityInputAction inputAction, RecognitionConfidenceLevel confidence, TimeSpan phraseDuration, DateTime phraseStartTime, string text);
722721

723722
#endregion Speech Keyword Events
724723

0 commit comments

Comments
 (0)