ParallelTranscriptHandler.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  3. * All rights reserved.
  4. *
  5. * Licensed under the Oculus SDK License Agreement (the "License");
  6. * you may not use the Oculus SDK except in compliance with the License,
  7. * which is provided at the time of installation or download, or which
  8. * otherwise accompanies this software in either electronic or hard copy form.
  9. *
  10. * You may obtain a copy of the License at
  11. *
  12. * https://developer.oculus.com/licenses/oculussdk/
  13. *
  14. * Unless required by applicable law or agreed to in writing, the Oculus SDK
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. using Meta.WitAi;
  21. using UnityEngine;
  22. namespace Oculus.Voice.Demo.UIShapesDemo
  23. {
  24. public class ParallelTranscriptHandler : MonoBehaviour
  25. {
  26. [Header("Transcript Requests")]
  27. [SerializeField] private string[] _requests;
  28. [Header("Voice")]
  29. [SerializeField] private VoiceService _voiceService;
  30. #if UNITY_EDITOR
  31. // Reset
  32. private string[] _activates = new string[] { "Set the", "Make the" };
  33. private string[] _shapes = new string[] { "cube", "sphere", "capsule", "cylinder", "pentagon" };
  34. private string[] _colors = new string[] { "red", "blue", "yellow", "green", "orange", "purple", "magenta", "cyan", "brown", "white", "black" };
  35. private void Reset()
  36. {
  37. int index = 0;
  38. _requests = new string[_activates.Length * _shapes.Length * _colors.Length];
  39. for (int a = 0; a < _activates.Length; a++)
  40. {
  41. for (int c = 0; c < _colors.Length; c++)
  42. {
  43. for (int s = 0; s < _shapes.Length; s++)
  44. {
  45. _requests[index] = $"{_activates[a]} {_shapes[s]} {_colors[c]}";
  46. index++;
  47. }
  48. }
  49. }
  50. }
  51. #endif
  52. public void SendParallelRequests()
  53. {
  54. foreach (var request in _requests)
  55. {
  56. _voiceService.Activate(request);
  57. }
  58. }
  59. }
  60. }