VoiceSDKBinding.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.Configuration;
  21. using Oculus.Voice.Core.Bindings.Android;
  22. using UnityEngine;
  23. namespace Oculus.Voice.Bindings.Android
  24. {
  25. public class VoiceSDKBinding : BaseServiceBinding
  26. {
  27. public VoiceSDKBinding(AndroidJavaObject sdkInstance) : base(sdkInstance)
  28. {
  29. }
  30. public bool Active => binding.Call<bool>("isActive");
  31. public bool IsRequestActive => binding.Call<bool>("isRequestActive");
  32. public bool MicActive => binding.Call<bool>("isMicActive");
  33. public bool PlatformSupportsWit => binding.Call<bool>("isSupported");
  34. public void Activate(string text, WitRequestOptions options)
  35. {
  36. binding.Call("activate", text, options.ToJsonString());
  37. }
  38. public void Activate(WitRequestOptions options)
  39. {
  40. binding.Call("activate", options.ToJsonString());
  41. }
  42. public void ActivateImmediately(WitRequestOptions options)
  43. {
  44. binding.Call("activateImmediately", options.ToJsonString());
  45. }
  46. public void Deactivate()
  47. {
  48. binding.Call("deactivate");
  49. }
  50. public void DeactivateAndAbortRequest()
  51. {
  52. binding.Call("deactivateAndAbortRequest");
  53. }
  54. public void SetRuntimeConfiguration(WitRuntimeConfiguration configuration)
  55. {
  56. binding.Call("setRuntimeConfig", new VoiceSDKConfigBinding(configuration).ToJavaObject());
  57. }
  58. public void SetListener(VoiceSDKListenerBinding listener)
  59. {
  60. binding.Call("setListener", listener);
  61. }
  62. public void Connect()
  63. {
  64. binding.Call<bool>("connect");
  65. }
  66. }
  67. }