Initial Commit

This commit is contained in:
2025-07-04 20:33:06 +03:00
commit 8f09347ae0
9219 changed files with 2447903 additions and 0 deletions
@@ -0,0 +1,28 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using Meta.WitAi.Data;
using UnityEngine;
namespace Meta.WitAi.Events
{
[Serializable]
public class AudioBufferEvents
{
public delegate void OnSampleReadyEvent(RingBuffer<byte>.Marker marker, float levelMax);
public OnSampleReadyEvent OnSampleReady;
[Tooltip("Called when the volume level of the mic input has changed")]
public WitMicLevelChangedEvent OnMicLevelChanged = new WitMicLevelChangedEvent();
[Header("Data")]
public WitByteDataEvent OnByteDataReady = new WitByteDataEvent();
public WitByteDataEvent OnByteDataSent = new WitByteDataEvent();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bd7c64da99e7e054c83dea7647d723b2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,16 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using UnityEngine.Events;
namespace Meta.WitAi.Events
{
public class AudioDurationTrackerFinishedEvent : UnityEvent<long, double>
{
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f8dfb56f054f4aaead7cf9a29003a1d1
timeCreated: 1670631381
@@ -0,0 +1,24 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using UnityEngine;
namespace Meta.WitAi.Events
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
public class EventCategoryAttribute : PropertyAttribute
{
public readonly string Category;
public EventCategoryAttribute(string category = "")
{
Category = category;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3c098352b8ac4407a48e88eec765e7c5
timeCreated: 1658192444
@@ -0,0 +1,56 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System.Collections.Generic;
using UnityEngine;
namespace Meta.WitAi.Events
{
public class EventRegistry
{
[SerializeField]
private List<string> _overriddenCallbacks = new List<string>();
private HashSet<string> _overriddenCallbacksHash;
public HashSet<string> OverriddenCallbacks
{
get
{
if (_overriddenCallbacksHash == null)
{
_overriddenCallbacksHash = new HashSet<string>(_overriddenCallbacks);
}
return _overriddenCallbacksHash;
}
}
public void RegisterOverriddenCallback(string callback)
{
if (!_overriddenCallbacks.Contains(callback))
{
_overriddenCallbacks.Add(callback);
_overriddenCallbacksHash.Add(callback);
}
}
public void RemoveOverriddenCallback(string callback)
{
if (_overriddenCallbacks.Contains(callback))
{
_overriddenCallbacks.Remove(callback);
_overriddenCallbacksHash.Remove(callback);
}
}
public bool IsCallbackOverridden(string callback)
{
return OverriddenCallbacks.Contains(callback);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: bb347bc947a144a4895c273b88f7baff
timeCreated: 1658874536
@@ -0,0 +1,16 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
namespace Meta.WitAi.Events
{
public class TelemetryEvents
{
public AudioDurationTrackerFinishedEvent OnAudioTrackerFinished =
new AudioDurationTrackerFinishedEvent();
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 671577dd5928458da0dfb66db09c5b95
timeCreated: 1670875696
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e46f5b77b81ea435ea3274e9d3ddceaa
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,59 @@
using Meta.WitAi.Interfaces;
using UnityEngine;
using UnityEngine.Events;
namespace Meta.WitAi.Events.UnityEventListeners
{
[RequireComponent(typeof(IAudioEventProvider))]
public class AudioEventListener : MonoBehaviour, IAudioInputEvents
{
[SerializeField] private WitMicLevelChangedEvent onMicAudioLevelChanged = new WitMicLevelChangedEvent();
[SerializeField] private UnityEvent onMicStartedListening = new UnityEvent();
[SerializeField] private UnityEvent onMicStoppedListening = new UnityEvent();
public WitMicLevelChangedEvent OnMicAudioLevelChanged => onMicAudioLevelChanged;
public UnityEvent OnMicStartedListening => onMicStartedListening;
public UnityEvent OnMicStoppedListening => onMicStoppedListening;
private IAudioInputEvents _events;
private IAudioInputEvents AudioInputEvents
{
get
{
if (null == _events)
{
var eventProvider = GetComponent<IAudioEventProvider>();
if (null != eventProvider)
{
_events = eventProvider.AudioEvents;
}
}
return _events;
}
}
private void OnEnable()
{
var events = AudioInputEvents;
if (null != events)
{
events.OnMicAudioLevelChanged.AddListener(onMicAudioLevelChanged.Invoke);
events.OnMicStartedListening.AddListener(onMicStartedListening.Invoke);
events.OnMicStoppedListening.AddListener(onMicStoppedListening.Invoke);
}
}
private void OnDisable()
{
var events = AudioInputEvents;
if (null != events)
{
events.OnMicAudioLevelChanged.RemoveListener(onMicAudioLevelChanged.Invoke);
events.OnMicStartedListening.RemoveListener(onMicStartedListening.Invoke);
events.OnMicStoppedListening.RemoveListener(onMicStoppedListening.Invoke);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9b7e57a219bf949418f86fc9056e38ec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,55 @@
using Meta.WitAi.Interfaces;
using UnityEngine;
namespace Meta.WitAi.Events.UnityEventListeners
{
public class TranscriptionEventListener : MonoBehaviour, ITranscriptionEvent
{
[SerializeField] private WitTranscriptionEvent onPartialTranscription = new
WitTranscriptionEvent();
[SerializeField] private WitTranscriptionEvent onFullTranscription = new
WitTranscriptionEvent();
public WitTranscriptionEvent OnPartialTranscription => onPartialTranscription;
public WitTranscriptionEvent OnFullTranscription => onFullTranscription;
private ITranscriptionEvent _events;
private ITranscriptionEvent TranscriptionEvents
{
get
{
if (null == _events)
{
var eventProvider = GetComponent<ITranscriptionEventProvider>();
if (null != eventProvider)
{
_events = eventProvider.TranscriptionEvents;
}
}
return _events;
}
}
private void OnEnable()
{
var events = TranscriptionEvents;
if (null != events)
{
events.OnPartialTranscription.AddListener(onPartialTranscription.Invoke);
events.OnFullTranscription.AddListener(onFullTranscription.Invoke);
}
}
private void OnDisable()
{
var events = TranscriptionEvents;
if (null != events)
{
events.OnPartialTranscription.RemoveListener(onPartialTranscription.Invoke);
events.OnFullTranscription.RemoveListener(onFullTranscription.Invoke);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d4753c88442c94393b915563ef1b41cf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,36 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using UnityEngine;
using UnityEngine.Serialization;
namespace Meta.WitAi.Events
{
[Serializable]
public class VoiceEvents : SpeechEvents
{
private const string EVENT_CATEGORY_DATA_EVENTS = "Data Events";
[EventCategory(EVENT_CATEGORY_DATA_EVENTS)]
[FormerlySerializedAs("OnByteDataReady")] [SerializeField] [HideInInspector]
private WitByteDataEvent _onByteDataReady = new WitByteDataEvent();
public WitByteDataEvent OnByteDataReady => _onByteDataReady;
[EventCategory(EVENT_CATEGORY_DATA_EVENTS)]
[FormerlySerializedAs("OnByteDataSent")] [SerializeField] [HideInInspector]
private WitByteDataEvent _onByteDataSent = new WitByteDataEvent();
public WitByteDataEvent OnByteDataSent => _onByteDataSent;
[EventCategory(EVENT_CATEGORY_ACTIVATION_RESPONSE)]
[Tooltip("Called after an on partial response to validate data. If data.validResponse is true, service will deactivate & use the partial data as final")]
[FormerlySerializedAs("OnValidatePartialResponse")] [SerializeField]
private WitValidationEvent _onValidatePartialResponse = new WitValidationEvent();
public WitValidationEvent OnValidatePartialResponse => _onValidatePartialResponse;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 371044f8a8a85b34aa78547a31c99aa0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using Meta.WitAi.Requests;
using UnityEngine.Events;
namespace Meta.WitAi.Events
{
[Serializable]
public class VoiceServiceRequestEvent : UnityEvent<VoiceServiceRequest> { }
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5a88978da4d44ed4f962061566872b83
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,24 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
namespace Meta.WitAi.Events
{
[Flags]
public enum VoiceState
{
MicOff = 1, //000001
MicOn = 2, //000010
Listening = 4,//000100
StartProcessing = 8,//001000
Response = 16,//010000
Error = 32, //100000
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f3a30f8f7e33c754484eaa264d133f25
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,26 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using UnityEngine.Events;
namespace Meta.WitAi.Events
{
[Serializable]
public class WitByteDataEvent : UnityEvent<byte[], int, int> { }
public interface IWitByteDataReadyHandler
{
void OnWitDataReady(byte[] data, int offset, int length);
}
public interface IWitByteDataSentHandler
{
void OnWitDataSent(byte[] data, int offset, int length);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f9f9db5737a746f19c8b874380099f09
timeCreated: 1643225148
@@ -0,0 +1,24 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using UnityEngine.Events;
namespace Meta.WitAi.Events
{
/// <summary>
/// An error event with two parameters.
///
/// Param 1: error - the type of error that occurred
/// Param 2: message - A human readable message describing the error
/// </summary>
[Serializable]
public class WitErrorEvent : UnityEvent<string, string>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8a3a49a4b636e7e4d937f923f434789a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using UnityEngine.Events;
namespace Meta.WitAi.Events
{
[Serializable]
public class WitMicLevelChangedEvent : UnityEvent<float>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 533049bdcc7a20a41b6fc9f90b951fd0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,23 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using Meta.WitAi.Json;
using UnityEngine.Events;
namespace Meta.WitAi.Events
{
/// <summary>
/// Events that include WitResponseClass data
/// </summary>
[Serializable]
public class WitObjectEvent : UnityEvent<WitResponseClass>
{
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3f1ce8c1e935431ba45959b974e24741
timeCreated: 1685560556
@@ -0,0 +1,19 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using UnityEngine.Events;
namespace Meta.WitAi.Events
{
[Serializable]
public class WitRequestCreatedEvent : UnityEvent<WitRequest>
{
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2134bc577e5e4ae2a9a3a1e37f1ac0dc
timeCreated: 1623191846
@@ -0,0 +1,20 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using Meta.WitAi.Configuration;
using UnityEngine.Events;
namespace Meta.WitAi.Events
{
[Serializable]
public class WitRequestOptionsEvent : UnityEvent<WitRequestOptions>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c6d84414ef13f4c44a49c1311a65818b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,19 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using Meta.WitAi.Json;
using UnityEngine.Events;
namespace Meta.WitAi.Events
{
[Serializable]
public class WitResponseEvent : UnityEvent<WitResponseNode>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7ef88cd3e80185c4a90060968bd7c213
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,16 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using UnityEngine.Events;
namespace Meta.WitAi.Events
{
[Serializable]
public class WitTranscriptionEvent : UnityEvent<string> { }
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 984bfa2088e54a9ca440be6b82c17409
timeCreated: 1627418910
@@ -0,0 +1,19 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
using System;
using Meta.WitAi.Data;
using UnityEngine.Events;
namespace Meta.WitAi.Events
{
[Serializable]
public class WitValidationEvent : UnityEvent<VoiceSession>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ac70bc3fd716e564cb85c2e27b561144
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: