Initial Commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 99387caa63da84115b622a0d8cdfeaa9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 Meta.WitAi;
|
||||
using Meta.WitAi.Configuration;
|
||||
using Oculus.Voice.Dictation.Configuration;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Voice.Dictation.Bindings.Android
|
||||
{
|
||||
public class DictationConfigurationBinding
|
||||
{
|
||||
private readonly WitDictationRuntimeConfiguration _runtimeConfiguration;
|
||||
private readonly DictationConfiguration _dictationConfiguration;
|
||||
private readonly int MAX_PLATFORM_SUPPORTED_RECORDING_TIME_SECONDS = 300;
|
||||
|
||||
public DictationConfigurationBinding(WitDictationRuntimeConfiguration runtimeConfiguration)
|
||||
{
|
||||
if (null == runtimeConfiguration)
|
||||
{
|
||||
// No config defined, use the default configuration.
|
||||
VLog.W("No dictation config has been defined. Using the default configuration.");
|
||||
_dictationConfiguration = new DictationConfiguration();
|
||||
}
|
||||
else
|
||||
{
|
||||
_dictationConfiguration = runtimeConfiguration.dictationConfiguration;
|
||||
_runtimeConfiguration = runtimeConfiguration;
|
||||
}
|
||||
}
|
||||
|
||||
public AndroidJavaObject ToJavaObject()
|
||||
{
|
||||
AndroidJavaObject jo = new AndroidJavaObject("com.oculus.assistant.api.voicesdk.dictation.PlatformDictationConfiguration");
|
||||
jo.Set("multiPhrase", _dictationConfiguration.multiPhrase);
|
||||
jo.Set("scenario", _dictationConfiguration.scenario);
|
||||
jo.Set("inputType", _dictationConfiguration.inputType);
|
||||
if (_runtimeConfiguration != null)
|
||||
{
|
||||
int maxRecordingTime = (int) _runtimeConfiguration.maxRecordingTime;
|
||||
if (maxRecordingTime < 0)
|
||||
{
|
||||
maxRecordingTime = MAX_PLATFORM_SUPPORTED_RECORDING_TIME_SECONDS;
|
||||
}
|
||||
jo.Set("interactionTimeoutSeconds", maxRecordingTime);
|
||||
}
|
||||
|
||||
return jo;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c72e9e84ab9e87741986d6efe576e0d9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 UnityEngine;
|
||||
using Meta.WitAi;
|
||||
using Meta.WitAi.Dictation;
|
||||
using Meta.WitAi.Dictation.Data;
|
||||
using Meta.WitAi.Dictation.Events;
|
||||
|
||||
namespace Oculus.Voice.Dictation.Bindings.Android
|
||||
{
|
||||
public class DictationListenerBinding : AndroidJavaProxy
|
||||
{
|
||||
private IDictationService _dictationService;
|
||||
private IServiceEvents _serviceEvents;
|
||||
private DictationEvents DictationEvents => _dictationService.DictationEvents;
|
||||
|
||||
public DictationListenerBinding(IDictationService dictationService, IServiceEvents serviceEvents)
|
||||
: base("com.oculus.assistant.api.voicesdk.dictation.PlatformDictationListener")
|
||||
{
|
||||
_dictationService = dictationService;
|
||||
_serviceEvents = serviceEvents;
|
||||
}
|
||||
|
||||
public void onStart(string sessionId)
|
||||
{
|
||||
DictationEvents.OnStartListening?.Invoke();
|
||||
DictationSession session = new PlatformDictationSession()
|
||||
{
|
||||
dictationService = _dictationService,
|
||||
platformSessionId = sessionId
|
||||
};
|
||||
}
|
||||
|
||||
public void onMicAudioLevel(string sessionId, int micLevel)
|
||||
{
|
||||
DictationEvents.OnMicAudioLevelChanged?.Invoke(micLevel / 100.0f);
|
||||
}
|
||||
|
||||
public void onPartialTranscription(string sessionId, string transcription)
|
||||
{
|
||||
DictationEvents.OnPartialTranscription?.Invoke(transcription);
|
||||
}
|
||||
|
||||
public void onFinalTranscription(string sessionId, string transcription)
|
||||
{
|
||||
DictationEvents.OnFullTranscription?.Invoke(transcription);
|
||||
}
|
||||
|
||||
public void onError(string sessionId, string errorType, string errorMessage)
|
||||
{
|
||||
DictationEvents.OnError?.Invoke(errorType, errorMessage);
|
||||
}
|
||||
|
||||
public void onStopped(string sessionId)
|
||||
{
|
||||
DictationEvents.OnStoppedListening?.Invoke();
|
||||
DictationSession session = new PlatformDictationSession()
|
||||
{
|
||||
dictationService = _dictationService,
|
||||
platformSessionId = sessionId
|
||||
};
|
||||
}
|
||||
|
||||
public void onServiceNotAvailable(string error, string message)
|
||||
{
|
||||
VLog.W("Platform dictation service is not available");
|
||||
_serviceEvents.OnServiceNotAvailable(error, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ae8a1a01ce0f484eafa3e39954356dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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.
|
||||
*/
|
||||
|
||||
namespace Oculus.Voice.Dictation.Bindings.Android
|
||||
{
|
||||
public interface IServiceEvents
|
||||
{
|
||||
void OnServiceNotAvailable(string error, string message);
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d37d74b88e6244ad83c9242662e8dd7c
|
||||
timeCreated: 1655489373
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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;
|
||||
using Meta.WitAi.Configuration;
|
||||
using Meta.WitAi.Dictation;
|
||||
using Meta.WitAi.Dictation.Events;
|
||||
using Meta.WitAi.Events;
|
||||
using Meta.WitAi.Interfaces;
|
||||
using Meta.WitAi.Requests;
|
||||
using Meta.WitAi.Utilities;
|
||||
using Oculus.Voice.Core.Bindings.Android;
|
||||
using Oculus.Voice.Dictation.Configuration;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Oculus.Voice.Dictation.Bindings.Android
|
||||
{
|
||||
public class PlatformDictationImpl : BaseAndroidConnectionImpl<PlatformDictationSDKBinding>, IDictationService, IServiceEvents
|
||||
{
|
||||
private readonly IDictationService _baseService;
|
||||
private bool _serviceAvailable = true;
|
||||
private WitDictationRuntimeConfiguration _dictationRuntimeConfiguration;
|
||||
public PlatformDictationImpl(IDictationService dictationService)
|
||||
: base("com.oculus.assistant.api.unity.dictation.UnityDictationServiceFragment")
|
||||
{
|
||||
_baseService = dictationService;
|
||||
}
|
||||
|
||||
private DictationListenerBinding _listenerBinding;
|
||||
|
||||
public bool PlatformSupportsDictation => service.IsSupported && _serviceAvailable;
|
||||
public bool Active => service.Active;
|
||||
public bool IsRequestActive => service.IsRequestActive;
|
||||
public bool MicActive => service.Active;
|
||||
public ITranscriptionProvider TranscriptionProvider { get; set; }
|
||||
|
||||
public DictationEvents DictationEvents
|
||||
{
|
||||
get => _baseService.DictationEvents;
|
||||
set => _baseService.DictationEvents = value;
|
||||
}
|
||||
|
||||
public TelemetryEvents TelemetryEvents
|
||||
{
|
||||
get => _baseService.TelemetryEvents;
|
||||
set => _baseService.TelemetryEvents = value;
|
||||
}
|
||||
|
||||
public Action OnServiceNotAvailableEvent;
|
||||
|
||||
public override void Connect(string version)
|
||||
{
|
||||
base.Connect(version);
|
||||
_listenerBinding = new DictationListenerBinding(this, this);
|
||||
service.SetListener(_listenerBinding);
|
||||
}
|
||||
|
||||
public override void Disconnect()
|
||||
{
|
||||
base.Disconnect();
|
||||
}
|
||||
|
||||
public void SetDictationRuntimeConfiguration(WitDictationRuntimeConfiguration configuration)
|
||||
{
|
||||
_dictationRuntimeConfiguration = configuration;
|
||||
}
|
||||
|
||||
private void Activate()
|
||||
{
|
||||
service.StartDictation(new DictationConfigurationBinding(_dictationRuntimeConfiguration));
|
||||
}
|
||||
|
||||
public VoiceServiceRequest Activate(WitRequestOptions requestOptions, VoiceServiceRequestEvents requestEvents)
|
||||
{
|
||||
Activate();
|
||||
return null;
|
||||
}
|
||||
|
||||
public VoiceServiceRequest ActivateImmediately(WitRequestOptions requestOptions, VoiceServiceRequestEvents requestEvents)
|
||||
{
|
||||
Activate();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
service.StopDictation();
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
// TODO: T141779167
|
||||
service.StopDictation();
|
||||
}
|
||||
|
||||
public void OnServiceNotAvailable(string error, string message)
|
||||
{
|
||||
_serviceAvailable = false;
|
||||
OnServiceNotAvailableEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5199f2cf269c82348a4fe76b61d885e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 UnityEngine;
|
||||
using Oculus.Voice.Core.Bindings.Android;
|
||||
|
||||
namespace Oculus.Voice.Dictation.Bindings.Android
|
||||
{
|
||||
public class PlatformDictationSDKBinding : BaseServiceBinding
|
||||
{
|
||||
public bool Active => binding.Call<bool>("isActive");
|
||||
public bool IsRequestActive => binding.Call<bool>("isRequestActive");
|
||||
public bool IsSupported => binding.Call<bool>("isSupported");
|
||||
|
||||
public PlatformDictationSDKBinding(AndroidJavaObject sdkInstance) : base(sdkInstance) {}
|
||||
|
||||
public void StartDictation(DictationConfigurationBinding configuration)
|
||||
{
|
||||
binding.Call("startDictation", configuration.ToJavaObject());
|
||||
}
|
||||
|
||||
public void StopDictation()
|
||||
{
|
||||
binding.Call("stopDictation");
|
||||
}
|
||||
|
||||
public void SetListener(DictationListenerBinding listenerBinding)
|
||||
{
|
||||
binding.Call("setListener", listenerBinding);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41af6918ebf13234e857ebfc290db6ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus 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 Meta.WitAi.Dictation.Data;
|
||||
|
||||
namespace Oculus.Voice.Dictation.Bindings.Android
|
||||
{
|
||||
public class PlatformDictationSession : DictationSession
|
||||
{
|
||||
/// <summary>
|
||||
/// Session ID provided by the platform
|
||||
/// </summary>
|
||||
public string platformSessionId;
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87bac4c0262b45dcbbf302346ee10eb4
|
||||
timeCreated: 1657570862
|
||||
Reference in New Issue
Block a user