clean project
This commit is contained in:
3
Assets/Oculus/Voice/Scripts/Runtime/Bindings.meta
Normal file
3
Assets/Oculus/Voice/Scripts/Runtime/Bindings.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbc4c49e0d6b4e739b6daa5d08e00632
|
||||
timeCreated: 1630370504
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10a5b9b665ad462cb8d1e8d6cde9bc11
|
||||
timeCreated: 1630370518
|
||||
@@ -0,0 +1,75 @@
|
||||
/**************************************************************************************************
|
||||
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
*
|
||||
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
**************************************************************************************************/
|
||||
|
||||
using Facebook.WitAi.Configuration;
|
||||
using Oculus.Voice.Core.Bindings.Android;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Voice.Bindings.Android
|
||||
{
|
||||
public class VoiceSDKBinding : BaseServiceBinding
|
||||
{
|
||||
public VoiceSDKBinding(AndroidJavaObject sdkInstance) : base(sdkInstance)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Active => binding.Call<bool>("isActive");
|
||||
public bool IsRequestActive => binding.Call<bool>("isRequestActive");
|
||||
public bool MicActive => binding.Call<bool>("isMicActive");
|
||||
public bool PlatformSupportsWit => binding.Call<bool>("platformSupportsWit");
|
||||
|
||||
public void Activate(string text)
|
||||
{
|
||||
binding.Call("activate", text);
|
||||
}
|
||||
|
||||
public void Activate(string text, WitRequestOptions options)
|
||||
{
|
||||
binding.Call("activate", text);
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
binding.Call("activate");
|
||||
}
|
||||
|
||||
public void Activate(WitRequestOptions options)
|
||||
{
|
||||
binding.Call("activate");
|
||||
}
|
||||
|
||||
public void ActivateImmediately()
|
||||
{
|
||||
binding.Call("activateImmediately");
|
||||
}
|
||||
|
||||
public void ActivateImmediately(WitRequestOptions options)
|
||||
{
|
||||
binding.Call("activateImmediately");
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
binding.Call("deactivate");
|
||||
}
|
||||
|
||||
public void SetRuntimeConfiguration(WitRuntimeConfiguration configuration)
|
||||
{
|
||||
binding.Call("setRuntimeConfig", new VoiceSDKConfigBinding(configuration).ToJavaObject());
|
||||
}
|
||||
|
||||
public void SetListener(VoiceSDKListenerBinding listener)
|
||||
{
|
||||
binding.Call("setListener", listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d8c1d6d5b8545cfb741ca067158491a
|
||||
timeCreated: 1630371197
|
||||
@@ -0,0 +1,55 @@
|
||||
/**************************************************************************************************
|
||||
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
*
|
||||
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
**************************************************************************************************/
|
||||
|
||||
using Facebook.WitAi.Configuration;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Voice.Bindings.Android
|
||||
{
|
||||
public class VoiceSDKConfigBinding
|
||||
{
|
||||
private WitRuntimeConfiguration configuration;
|
||||
|
||||
public VoiceSDKConfigBinding(WitRuntimeConfiguration config)
|
||||
{
|
||||
configuration = config;
|
||||
}
|
||||
|
||||
public AndroidJavaObject ToJavaObject()
|
||||
{
|
||||
AndroidJavaObject witConfig =
|
||||
new AndroidJavaObject("com.oculus.voice.sdk.api.WitConfiguration");
|
||||
witConfig.Set("clientAccessToken", configuration.witConfiguration.clientAccessToken);
|
||||
|
||||
AndroidJavaObject witRuntimeConfig = new AndroidJavaObject("com.oculus.voice.sdk.api.WitRuntimeConfiguration");
|
||||
witRuntimeConfig.Set("witConfiguration", witConfig);
|
||||
|
||||
witRuntimeConfig.Set("minKeepAliveVolume", configuration.minKeepAliveVolume);
|
||||
witRuntimeConfig.Set("minKeepAliveTimeInSeconds",
|
||||
configuration.minKeepAliveTimeInSeconds);
|
||||
witRuntimeConfig.Set("minTranscriptionKeepAliveTimeInSeconds",
|
||||
configuration.minTranscriptionKeepAliveTimeInSeconds);
|
||||
witRuntimeConfig.Set("maxRecordingTime",
|
||||
configuration.maxRecordingTime);
|
||||
witRuntimeConfig.Set("soundWakeThreshold",
|
||||
configuration.soundWakeThreshold);
|
||||
witRuntimeConfig.Set("sampleLengthInMs",
|
||||
configuration.sampleLengthInMs);
|
||||
witRuntimeConfig.Set("micBufferLengthInSeconds",
|
||||
configuration.micBufferLengthInSeconds);
|
||||
witRuntimeConfig.Set("sendAudioToWit",
|
||||
configuration.sendAudioToWit);
|
||||
|
||||
return witRuntimeConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 114218fd50f24874adaaf0e91a865d75
|
||||
timeCreated: 1630370973
|
||||
@@ -0,0 +1,93 @@
|
||||
/**************************************************************************************************
|
||||
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
*
|
||||
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
**************************************************************************************************/
|
||||
|
||||
using Facebook.WitAi.Configuration;
|
||||
using Facebook.WitAi.Events;
|
||||
using Facebook.WitAi.Interfaces;
|
||||
using Oculus.Voice.Core.Bindings.Android;
|
||||
using Oculus.Voice.Interfaces;
|
||||
|
||||
namespace Oculus.Voice.Bindings.Android
|
||||
{
|
||||
public class VoiceSDKImpl : BaseAndroidConnectionImpl<VoiceSDKBinding>,
|
||||
IPlatformVoiceService
|
||||
{
|
||||
public VoiceSDKImpl() : base(
|
||||
"com.oculus.voice.sdk.unity.UnityVoiceSDKServiceFragment")
|
||||
{
|
||||
}
|
||||
|
||||
public bool PlatformSupportsWit => service.PlatformSupportsWit;
|
||||
|
||||
public bool Active => service.Active;
|
||||
public bool IsRequestActive => service.IsRequestActive;
|
||||
public bool MicActive => service.MicActive;
|
||||
public void SetRuntimeConfiguration(WitRuntimeConfiguration configuration)
|
||||
{
|
||||
service.SetRuntimeConfiguration(configuration);
|
||||
}
|
||||
|
||||
private VoiceSDKListenerBinding eventBinding;
|
||||
|
||||
public VoiceEvents VoiceEvents
|
||||
{
|
||||
get => eventBinding.VoiceEvents;
|
||||
set
|
||||
{
|
||||
eventBinding = new VoiceSDKListenerBinding(value);
|
||||
service.SetListener(eventBinding);
|
||||
}
|
||||
}
|
||||
|
||||
public ITranscriptionProvider TranscriptionProvider { get; set; }
|
||||
|
||||
public void Activate(string text)
|
||||
{
|
||||
service.Activate(text);
|
||||
}
|
||||
|
||||
public void Activate(string text, WitRequestOptions requestOptions)
|
||||
{
|
||||
service.Activate(text, requestOptions);
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
service.Activate();
|
||||
}
|
||||
|
||||
public void Activate(WitRequestOptions requestOptions)
|
||||
{
|
||||
service.Activate(requestOptions);
|
||||
}
|
||||
|
||||
public void ActivateImmediately()
|
||||
{
|
||||
service.ActivateImmediately();
|
||||
}
|
||||
|
||||
public void ActivateImmediately(WitRequestOptions requestOptions)
|
||||
{
|
||||
service.ActivateImmediately(requestOptions);
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
service.Deactivate();
|
||||
}
|
||||
|
||||
public void DeactivateAndAbortRequest()
|
||||
{
|
||||
service.Deactivate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3943048f6aa4a49977131e8fb7f677d
|
||||
timeCreated: 1630370598
|
||||
@@ -0,0 +1,96 @@
|
||||
/************************************************************************************
|
||||
Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
|
||||
Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
https://developer.oculus.com/licenses/oculussdk/
|
||||
|
||||
Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
ANY KIND, either express or implied. See the License for the specific language governing
|
||||
permissions and limitations under the License.
|
||||
************************************************************************************/
|
||||
|
||||
using Facebook.WitAi.Events;
|
||||
using Facebook.WitAi.Lib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Voice.Bindings.Android
|
||||
{
|
||||
public class VoiceSDKListenerBinding : AndroidJavaProxy
|
||||
{
|
||||
private VoiceEvents voiceEvents;
|
||||
|
||||
public VoiceEvents VoiceEvents => voiceEvents;
|
||||
|
||||
public VoiceSDKListenerBinding(VoiceEvents voiceEvents) : base(
|
||||
"com.oculus.assistant.api.unity.dictation.UnityDictationListener")
|
||||
{
|
||||
this.voiceEvents = voiceEvents;
|
||||
}
|
||||
|
||||
public void onResponse(string response)
|
||||
{
|
||||
voiceEvents.OnResponse?.Invoke(WitResponseNode.Parse(response));
|
||||
}
|
||||
|
||||
public void onError(string error, string message)
|
||||
{
|
||||
voiceEvents.OnError?.Invoke(error, message);
|
||||
}
|
||||
|
||||
public void onMicLevelChanged(float level)
|
||||
{
|
||||
voiceEvents.OnMicLevelChanged?.Invoke(level);
|
||||
}
|
||||
|
||||
public void onRequestCreated()
|
||||
{
|
||||
voiceEvents.OnRequestCreated?.Invoke(null);
|
||||
}
|
||||
|
||||
public void onStartListening()
|
||||
{
|
||||
voiceEvents.OnStartListening?.Invoke();
|
||||
}
|
||||
|
||||
public void onStoppedListening()
|
||||
{
|
||||
voiceEvents.OnStoppedListening?.Invoke();
|
||||
}
|
||||
|
||||
public void onStoppedListeningDueToInactivity()
|
||||
{
|
||||
voiceEvents.OnStoppedListeningDueToInactivity?.Invoke();
|
||||
}
|
||||
|
||||
public void onStoppedListeningDueToTimeout()
|
||||
{
|
||||
voiceEvents.OnStoppedListeningDueToTimeout?.Invoke();
|
||||
}
|
||||
|
||||
public void onStoppedListeningDueToDeactivation()
|
||||
{
|
||||
voiceEvents.OnStoppedListeningDueToDeactivation?.Invoke();
|
||||
}
|
||||
|
||||
public void onMicDataSent()
|
||||
{
|
||||
voiceEvents.OnMicDataSent?.Invoke();
|
||||
}
|
||||
|
||||
public void onMinimumWakeThresholdHit()
|
||||
{
|
||||
voiceEvents.OnMinimumWakeThresholdHit?.Invoke();
|
||||
}
|
||||
|
||||
public void onPartialTranscription(string transcription)
|
||||
{
|
||||
voiceEvents.OnPartialTranscription?.Invoke(transcription);
|
||||
}
|
||||
|
||||
public void onFullTranscription(string transcription)
|
||||
{
|
||||
voiceEvents.OnFullTranscription?.Invoke(transcription);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4812e4a88b84256a571c7253e27799f
|
||||
timeCreated: 1630371293
|
||||
3
Assets/Oculus/Voice/Scripts/Runtime/Interfaces.meta
Normal file
3
Assets/Oculus/Voice/Scripts/Runtime/Interfaces.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44a9302c8ca946f3b19b222b1481aa72
|
||||
timeCreated: 1630374670
|
||||
@@ -0,0 +1,24 @@
|
||||
/**************************************************************************************************
|
||||
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
*
|
||||
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
**************************************************************************************************/
|
||||
|
||||
using Facebook.WitAi;
|
||||
using Facebook.WitAi.Configuration;
|
||||
|
||||
namespace Oculus.Voice.Interfaces
|
||||
{
|
||||
public interface IPlatformVoiceService : IVoiceService
|
||||
{
|
||||
bool PlatformSupportsWit { get; }
|
||||
|
||||
void SetRuntimeConfiguration(WitRuntimeConfiguration configuration);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64225fc2964c4ee98ff780eb51274278
|
||||
timeCreated: 1630374685
|
||||
8
Assets/Oculus/Voice/Scripts/Runtime/Service.meta
Normal file
8
Assets/Oculus/Voice/Scripts/Runtime/Service.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8e4f817930837444a893fce723ba3f6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
163
Assets/Oculus/Voice/Scripts/Runtime/Service/AppBuiltIns.cs
Normal file
163
Assets/Oculus/Voice/Scripts/Runtime/Service/AppBuiltIns.cs
Normal file
@@ -0,0 +1,163 @@
|
||||
/**************************************************************************************************
|
||||
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
*
|
||||
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
**************************************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Oculus.Voice
|
||||
{
|
||||
public static class AppBuiltIns
|
||||
{
|
||||
public static string builtInPrefix = "builtin:";
|
||||
private static string modelName = "Built-in Models";
|
||||
|
||||
public static readonly Dictionary<string, Dictionary<string, string>>
|
||||
apps = new Dictionary<string, Dictionary<string, string>>
|
||||
{
|
||||
{
|
||||
"Chinese", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_zh"},
|
||||
{"name", modelName},
|
||||
{"lang", "zh"},
|
||||
{"clientToken", "3KQH33637TAT7WD4TG7T65SDRO73WZGY"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"Dutch", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_nl"},
|
||||
{"name", modelName},
|
||||
{"lang", "nl"},
|
||||
{"clientToken", "ZCD6HCNCL6GTJKZ3QKWNKQVEDI4GUL7C"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"English", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_en"},
|
||||
{"name", modelName},
|
||||
{"lang", "en"},
|
||||
{"clientToken", "HOKEABS7HPIQVSRSVWRPTTV75TQJ5QBP"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"French", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_fr"},
|
||||
{"name", modelName},
|
||||
{"lang", "fr"},
|
||||
{"clientToken", "7PP7NK2QAH67MREGZV6SB6RIEWAYDNRY"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"German", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_de"},
|
||||
{"name", modelName},
|
||||
{"lang", "de"},
|
||||
{"clientToken", "7LXOOB4JC7MXPUTTGQHDVQMHGEEJT6LE"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"Italian", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_it"},
|
||||
{"name", modelName},
|
||||
{"lang", "it"},
|
||||
{"clientToken", "KELCNR4DCCPPOCF2RDFS4M6JOCWWIFII"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"Japanese", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_ja"},
|
||||
{"name", modelName},
|
||||
{"lang", "ja"},
|
||||
{"clientToken", "TPJGLBBCHJ5F7BVVN5XLEGP6YDQRUE3P"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"Korean", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_ko"},
|
||||
{"name", modelName},
|
||||
{"lang", "ko"},
|
||||
{"clientToken", "NT4WJLL7ACMFBXS4B7W5GRLTKDZQ36R4"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"Polish", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_pl"},
|
||||
{"name", modelName},
|
||||
{"lang", "pl"},
|
||||
{"clientToken", "DMDRHGYDYN33D3IKCX5BG5R57EL2IIC4"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"Portuguese", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_pt"},
|
||||
{"name", modelName},
|
||||
{"lang", "pt"},
|
||||
{"clientToken", "W4W3BSKL72HZC5MXLILONJUCG732SQQN"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"Russian", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_ru"},
|
||||
{"name", modelName},
|
||||
{"lang", "ru"},
|
||||
{"clientToken", "W67HLUWA3MBYVEKRW3VVWUKSNZGAOFBI"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"Spanish", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_es"},
|
||||
{"name", modelName},
|
||||
{"lang", "es"},
|
||||
{"clientToken", "YW7AM5OOVSW5XKGYKFE2S2HLC2WHC3UI"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"Swedish", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_sv"},
|
||||
{"name", modelName},
|
||||
{"lang", "sv"},
|
||||
{"clientToken", "NPE3UJ7Y4NIVTUOZ7QPPAP3TY6FYPXJY"},
|
||||
}
|
||||
},
|
||||
{
|
||||
"Turkish", new Dictionary<string, string>
|
||||
{
|
||||
{"id", "voiceSDK_tr"},
|
||||
{"name", modelName},
|
||||
{"lang", "tr"},
|
||||
{"clientToken", "ZCISEDXESLYJOROLNOODCGGPZXHLUAEE"},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
public static string[] appNames
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] keys = new string[apps.Keys.Count];
|
||||
apps.Keys.CopyTo(keys, 0);
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6483d6b21054c4e07acfd6c1c43c4e0b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,153 @@
|
||||
/**************************************************************************************************
|
||||
* Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
|
||||
*
|
||||
* Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
|
||||
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
**************************************************************************************************/
|
||||
|
||||
using Facebook.WitAi;
|
||||
using Facebook.WitAi.Configuration;
|
||||
using Facebook.WitAi.Interfaces;
|
||||
#if UNITY_ANDROID
|
||||
using Oculus.Voice.Bindings.Android;
|
||||
#endif
|
||||
using Oculus.Voice.Interfaces;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Voice
|
||||
{
|
||||
[HelpURL("https://developer.oculus.com/experimental/voice-sdk/tutorial-overview/")]
|
||||
public class AppVoiceExperience : VoiceService, IWitRuntimeConfigProvider
|
||||
{
|
||||
[SerializeField] private WitRuntimeConfiguration witRuntimeConfiguration;
|
||||
|
||||
public WitRuntimeConfiguration RuntimeConfiguration
|
||||
{
|
||||
get => witRuntimeConfiguration;
|
||||
set => witRuntimeConfiguration = value;
|
||||
}
|
||||
|
||||
private IPlatformVoiceService platformService;
|
||||
private IVoiceService voiceServiceImpl;
|
||||
|
||||
#region Voice Service Properties
|
||||
public override bool Active => null != voiceServiceImpl && voiceServiceImpl.Active;
|
||||
public override bool IsRequestActive => null != voiceServiceImpl && voiceServiceImpl.IsRequestActive;
|
||||
public override ITranscriptionProvider TranscriptionProvider
|
||||
{
|
||||
get => voiceServiceImpl.TranscriptionProvider;
|
||||
set => voiceServiceImpl.TranscriptionProvider = value;
|
||||
|
||||
}
|
||||
public override bool MicActive => null != voiceServiceImpl && voiceServiceImpl.MicActive;
|
||||
protected override bool ShouldSendMicData => witRuntimeConfiguration.sendAudioToWit ||
|
||||
null == TranscriptionProvider;
|
||||
#endregion
|
||||
|
||||
public bool HasPlatformIntegrations => false;
|
||||
|
||||
#region Voice Service Methods
|
||||
|
||||
public override void Activate()
|
||||
{
|
||||
voiceServiceImpl.Activate();
|
||||
}
|
||||
|
||||
public override void Activate(WitRequestOptions options)
|
||||
{
|
||||
voiceServiceImpl.Activate(options);
|
||||
}
|
||||
|
||||
public override void ActivateImmediately()
|
||||
{
|
||||
voiceServiceImpl.ActivateImmediately();
|
||||
}
|
||||
|
||||
public override void ActivateImmediately(WitRequestOptions options)
|
||||
{
|
||||
voiceServiceImpl.ActivateImmediately(options);
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
voiceServiceImpl.Deactivate();
|
||||
}
|
||||
|
||||
public override void DeactivateAndAbortRequest()
|
||||
{
|
||||
voiceServiceImpl.DeactivateAndAbortRequest();
|
||||
}
|
||||
|
||||
public override void Activate(string text)
|
||||
{
|
||||
voiceServiceImpl.Activate(text);
|
||||
}
|
||||
|
||||
public override void Activate(string text, WitRequestOptions requestOptions)
|
||||
{
|
||||
voiceServiceImpl.Activate(text, requestOptions);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
void Start()
|
||||
{
|
||||
InitVoiceSDK();
|
||||
}
|
||||
|
||||
private void InitVoiceSDK()
|
||||
{
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
if (HasPlatformIntegrations)
|
||||
{
|
||||
IPlatformVoiceService platformImpl = new VoiceSDKImpl();
|
||||
if (platformImpl.PlatformSupportsWit)
|
||||
{
|
||||
voiceServiceImpl = platformImpl;
|
||||
}
|
||||
else
|
||||
{
|
||||
RevertToWitUnity();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RevertToWitUnity();
|
||||
}
|
||||
#else
|
||||
RevertToWitUnity();
|
||||
#endif
|
||||
|
||||
if (voiceServiceImpl is Wit wit)
|
||||
{
|
||||
wit.RuntimeConfiguration = witRuntimeConfiguration;
|
||||
}
|
||||
|
||||
voiceServiceImpl.VoiceEvents = VoiceEvents;
|
||||
}
|
||||
|
||||
private void RevertToWitUnity()
|
||||
{
|
||||
voiceServiceImpl = GetComponent<Wit>();
|
||||
if (null == voiceServiceImpl)
|
||||
{
|
||||
voiceServiceImpl = gameObject.AddComponent<Wit>();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if(null == voiceServiceImpl) InitVoiceSDK();
|
||||
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
platformService?.SetRuntimeConfiguration(witRuntimeConfiguration);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28779cfed47441a42a6cd4fb49c8dc89
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Oculus/Voice/Scripts/Runtime/VoiceSDK.Runtime.asmdef
Normal file
17
Assets/Oculus/Voice/Scripts/Runtime/VoiceSDK.Runtime.asmdef
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "VoiceSDK.Runtime",
|
||||
"references": [
|
||||
"GUID:a6b2b1f1f66ed4645a97660636b8683d",
|
||||
"GUID:a7c32ded21d3b9b42a71cdf39f2ed8da",
|
||||
"GUID:4504b1a6e0fdcc3498c30b266e4a63bf"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e545cc0678493234a9368f4e470c29e8
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user