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,8 @@
fileFormatVersion: 2
guid: a055de36d1eb600438a9672f8a87aa4f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,22 @@
fileFormatVersion: 2
guid: 08c3f8e8283d6b94880e22280a446d1b
AudioImporter:
externalObjects: {}
serializedVersion: 6
defaultSettings:
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b2aba7c73993fe740a6d88f6a3ebe8cc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,84 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Skybox
m_Shader: {fileID: 106, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _SUNDISK_HIGH_QUALITY
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AtmosphereThickness: 1.54
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _Exposure: 1
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _SunDisk: 2
- _SunSize: 0
- _SunSizeConvergence: 5
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _GroundColor: {r: 1, g: 1, b: 1, a: 1}
- _SkyTint: {r: 0.3773585, g: 0.2076738, b: 0, a: 1}
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eb25191ecaaa6864bb08fe4b3eea748c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a27fd263bcf896a4e84c59189d0e420f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,296 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3550832292187419422
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3550832292187419420}
- component: {fileID: 3550832292187419423}
- component: {fileID: 1295848615748463565}
m_Layer: 0
m_Name: TTSSpeaker
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3550832292187419420
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3550832292187419422}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 3550832292895390900}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &3550832292187419423
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3550832292187419422}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b15403450229c3a4b8455a61d6143a6d, type: 3}
m_Name:
m_EditorClassIdentifier:
PrependedText:
AppendedText:
presetVoiceID: CHARLIE
_ttsService: {fileID: 0}
AudioSource: {fileID: 3550832292895390901}
_cloneAudioSource: 0
_events:
OnTextPlaybackStart:
m_PersistentCalls:
m_Calls: []
OnTextPlaybackCancelled:
m_PersistentCalls:
m_Calls: []
OnTextPlaybackFinished:
m_PersistentCalls:
m_Calls: []
OnAudioClipPlaybackReady:
m_PersistentCalls:
m_Calls: []
OnAudioClipPlaybackStart:
m_PersistentCalls:
m_Calls: []
OnAudioClipPlaybackCancelled:
m_PersistentCalls:
m_Calls: []
OnAudioClipPlaybackFinished:
m_PersistentCalls:
m_Calls: []
_onLoadBegin:
m_PersistentCalls:
m_Calls: []
_onLoadAbort:
m_PersistentCalls:
m_Calls: []
_onLoadFailed:
m_PersistentCalls:
m_Calls: []
_onLoadSuccess:
m_PersistentCalls:
m_Calls: []
_onPlaybackReady:
m_PersistentCalls:
m_Calls: []
_onPlaybackStart:
m_PersistentCalls:
m_Calls: []
_onPlaybackCancelled:
m_PersistentCalls:
m_Calls: []
_onPlaybackClipUpdated:
m_PersistentCalls:
m_Calls: []
_onPlaybackComplete:
m_PersistentCalls:
m_Calls: []
_onPlaybackQueueBegin:
m_PersistentCalls:
m_Calls: []
_onPlaybackQueueComplete:
m_PersistentCalls:
m_Calls: []
OnClipDataQueued:
m_PersistentCalls:
m_Calls: []
OnClipLoadBegin:
m_PersistentCalls:
m_Calls: []
OnClipDataLoadBegin:
m_PersistentCalls:
m_Calls: []
OnClipLoadAbort:
m_PersistentCalls:
m_Calls: []
OnClipDataLoadAbort:
m_PersistentCalls:
m_Calls: []
OnClipLoadFailed:
m_PersistentCalls:
m_Calls: []
OnClipDataLoadFailed:
m_PersistentCalls:
m_Calls: []
OnClipLoadSuccess:
m_PersistentCalls:
m_Calls: []
OnClipDataLoadSuccess:
m_PersistentCalls:
m_Calls: []
OnClipDataPlaybackReady:
m_PersistentCalls:
m_Calls: []
OnStartSpeaking:
m_PersistentCalls:
m_Calls: []
OnClipDataPlaybackStart:
m_PersistentCalls:
m_Calls: []
OnCancelledSpeaking:
m_PersistentCalls:
m_Calls: []
OnClipDataPlaybackCancelled:
m_PersistentCalls:
m_Calls: []
OnFinishedSpeaking:
m_PersistentCalls:
m_Calls: []
OnClipDataPlaybackFinished:
m_PersistentCalls:
m_Calls: []
--- !u!114 &1295848615748463565
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3550832292187419422}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d2accdd3f9f0a354b84b364eae500512, type: 3}
m_Name:
m_EditorClassIdentifier:
MaxTextLength: 250
--- !u!1 &3550832292895390903
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3550832292895390900}
- component: {fileID: 3550832292895390901}
m_Layer: 0
m_Name: Voice
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3550832292895390900
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3550832292895390903}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 2, y: 1.665, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 3550832292187419420}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!82 &3550832292895390901
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3550832292895390903}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e7e41a5ed3743804eacae1e009586e72
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6ff7fbfe0243d604ea0d362d82d4baf2
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,251 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4852061571279439017
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4852061571279439020}
- component: {fileID: 4852061571279439023}
- component: {fileID: 3627599131962939471}
- component: {fileID: 4852061571279439022}
m_Layer: 0
m_Name: TTSWit
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4852061571279439020
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4852061571279439017}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &4852061571279439023
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4852061571279439017}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a6b3124b830442d45b9f357ff99b152f, type: 3}
m_Name:
m_EditorClassIdentifier:
_events:
OnClipCreated:
m_PersistentCalls:
m_Calls: []
OnClipUnloaded:
m_PersistentCalls:
m_Calls: []
Stream:
OnStreamBegin:
m_PersistentCalls:
m_Calls: []
OnStreamReady:
m_PersistentCalls:
m_Calls: []
OnStreamClipUpdate:
m_PersistentCalls:
m_Calls: []
OnStreamComplete:
m_PersistentCalls:
m_Calls: []
OnStreamCancel:
m_PersistentCalls:
m_Calls: []
OnStreamError:
m_PersistentCalls:
m_Calls: []
Download:
OnDownloadBegin:
m_PersistentCalls:
m_Calls: []
OnDownloadSuccess:
m_PersistentCalls:
m_Calls: []
OnDownloadCancel:
m_PersistentCalls:
m_Calls: []
OnDownloadError:
m_PersistentCalls:
m_Calls: []
RequestSettings:
configuration: {fileID: 11400000, guid: 6329e25e1005d4845b580a523e588979, type: 2}
audioType: 0
audioStream: 1
audioStreamReadyDuration: 0.1
audioStreamChunkLength: 5
audioStreamPreloadCount: 3
_presetVoiceSettings:
- SettingsId: CAEL
PrependedText:
AppendedText:
voice: Cael
style: default
speed: 100
pitch: 100
- SettingsId: CAM
PrependedText:
AppendedText:
voice: Cam
style: default
speed: 100
pitch: 100
- SettingsId: CARL
PrependedText:
AppendedText:
voice: Carl
style: default
speed: 100
pitch: 100
- SettingsId: CHARLIE
PrependedText:
AppendedText:
voice: Charlie
style: default
speed: 100
pitch: 100
- SettingsId: CODY
PrependedText:
AppendedText:
voice: Cody
style: default
speed: 100
pitch: 100
- SettingsId: CONNOR
PrependedText:
AppendedText:
voice: Connor
style: default
speed: 100
pitch: 100
- SettingsId: COOPER
PrependedText:
AppendedText:
voice: Cooper
style: default
speed: 100
pitch: 100
- SettingsId: PROSPECTOR
PrependedText:
AppendedText:
voice: Prospector
style: default
speed: 100
pitch: 100
- SettingsId: RAILEY
PrependedText:
AppendedText:
voice: Railey
style: default
speed: 100
pitch: 100
- SettingsId: REBECCA
PrependedText:
AppendedText:
voice: Rebecca
style: default
speed: 100
pitch: 100
- SettingsId: REMI
PrependedText:
AppendedText:
voice: Remi
style: default
speed: 100
pitch: 100
- SettingsId: RUBIE
PrependedText:
AppendedText:
voice: Rubie
style: default
speed: 100
pitch: 100
- SettingsId: VAMPIRE
PrependedText:
AppendedText:
voice: Vampire
style: default
speed: 100
pitch: 100
- SettingsId: COLIN
PrependedText:
AppendedText:
voice: Colin
style: default
speed: 100
pitch: 100
- SettingsId: ROSIE
PrependedText:
AppendedText:
voice: Rosie
style: default
speed: 100
pitch: 100
--- !u!114 &3627599131962939471
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4852061571279439017}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1d60dcb6d02034b4b96284db469db5e3, type: 3}
m_Name:
m_EditorClassIdentifier:
ClipLimit: 1
ClipCapacity: 100
RamLimit: 0
RamCapacity: 20000
--- !u!114 &4852061571279439022
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4852061571279439017}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b0ffdd015bcb8ea41bb96f19a723bf7d, type: 3}
m_Name:
m_EditorClassIdentifier:
_diskPath: TTS/
_defaultSettings:
DiskCacheLocation: 0
StreamFromDisk: 0
StreamBufferLength: 5
_events:
OnStreamBegin:
m_PersistentCalls:
m_Calls: []
OnStreamReady:
m_PersistentCalls:
m_Calls: []
OnStreamClipUpdate:
m_PersistentCalls:
m_Calls: []
OnStreamComplete:
m_PersistentCalls:
m_Calls: []
OnStreamCancel:
m_PersistentCalls:
m_Calls: []
OnStreamError:
m_PersistentCalls:
m_Calls: []
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3e919abfe68b0314aa3fa156a83435f2
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4d3b5c828cbc6c346a313c6a6ba35cac
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,16 @@
{
"name": "Meta.Voice.Samples.TTSVoices",
"references": [
"GUID:8bbcefc153e1f1b4a98680670797dd16",
"GUID:1c28d8b71ced07540b7c271537363cc6"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c4ae70944d4b73049b04afa3a1e912a7
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,397 @@
/*
* 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 Meta.WitAi;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
namespace Meta.Voice.Samples.TTSVoices
{
public class SimpleDropdownIndexEvent : UnityEvent<int> {}
public class SimpleDropdownOptionEvent : UnityEvent<string> {}
/// <summary>
/// A dropdown ui interface that uses 'UnityEngine.Text' labels and
/// builds content via a load method that accepts a list of strings.
/// </summary>
public class SimpleDropdownList : MonoBehaviour
{
[Header("Dropdown Toggle UI")]
[SerializeField] [Tooltip("Button used for speaker dropdown toggle")]
private Toggle _dropdownToggle;
[SerializeField] [Tooltip("Button arrow image showing open or closed")]
private Transform _dropdownButtonArrowImage;
[SerializeField] [Tooltip("Button text to be displayed without option selected")]
public string DropdownToggleUnselectedText = "...";
[Header("Dropdown List UI")]
[SerializeField] [Tooltip("Canvas used for dropdown popup")]
private CanvasGroup _dropdownListPopup;
[SerializeField] [Tooltip("Dropdown scroll rect used for the dropdown list")]
private ScrollRect _dropdownListScrollRect;
[SerializeField] [Tooltip("Prefab used for canvas dropdown list")]
private Toggle _dropdownListCellPrefab;
[SerializeField] [Tooltip("Additional text padding for dropdown cells")]
private float _dropdownCellTextPadding = 2f;
[SerializeField] [Tooltip("All available options for this dropdown")]
private string[] _options;
public string[] Options => _options;
[Header("Dropdown Default Settings")]
[SerializeField] [Tooltip("The current option selected")]
private int _selectedOptionIndex = -1;
public int SelectedOptionIndex => _selectedOptionIndex;
// Accessor for selected option
public string SelectedOption
{
get
{
if (_options != null && SelectedOptionIndex >= 0 && SelectedOptionIndex < _options.Length)
{
return _options[SelectedOptionIndex];
}
return null;
}
}
[SerializeField] [Tooltip("Dropdown callback event for selection by int")]
private SimpleDropdownIndexEvent _onIndexSelected = new SimpleDropdownIndexEvent();
public SimpleDropdownIndexEvent OnIndexSelected => _onIndexSelected;
[SerializeField] [Tooltip("Dropdown callback event for selection by option")]
private SimpleDropdownOptionEvent _onOptionSelected = new SimpleDropdownOptionEvent();
public SimpleDropdownOptionEvent OnOptionSelected => _onOptionSelected;
/// <summary>
/// Whether the popup is currently showing or not
/// </summary>
public bool IsShowing { get; private set; }
// Data currently being used
private List<Toggle> _cells = new List<Toggle>();
/// <summary>
/// On awake, find dropdown cell
/// </summary>
protected virtual void Awake()
{
FindCellPrefab();
}
// Find existing toggle if no prefab is assigned
private void FindCellPrefab()
{
if (_dropdownListCellPrefab == null)
{
_dropdownListCellPrefab = _dropdownListScrollRect.content.GetComponentInChildren<Toggle>();
if (_dropdownListCellPrefab != null)
{
_dropdownListCellPrefab.gameObject.SetActive(false);
}
else
{
Debug.LogError("No Dropdown Cell Prefab Found");
}
}
}
/// <summary>
/// Perform dropdown setup methods
/// </summary>
protected virtual void Start()
{
// Hide
SetShowing(false);
// Load dropdown
if (_options != null && _options.Length > 0)
{
LoadDropdown(Options);
}
// Force a selection refresh
int index = _selectedOptionIndex;
_selectedOptionIndex = index - 1;
SelectOption(index);
}
/// <summary>
/// Add toggle delegate
/// </summary>
protected virtual void OnEnable()
{
_dropdownToggle.onValueChanged.AddListener(OnToggleClick);
}
/// <summary>
/// Remove toggle delegate
/// </summary>
protected virtual void OnDisable()
{
_dropdownToggle.onValueChanged.RemoveListener(OnToggleClick);
}
#if ENABLE_LEGACY_INPUT_MANAGER
/// <summary>
/// Hide if touch outside of the scroll rect & toggle button
/// </summary>
protected virtual void Update()
{
if (IsShowing && Input.GetMouseButtonDown(0) && _dropdownListScrollRect != null && _dropdownToggle != null)
{
Vector2 touchPosition = Input.mousePosition;
if (!IsInRect(_dropdownListScrollRect.viewport, touchPosition)
&& !IsInRect(_dropdownToggle.GetComponent<RectTransform>(), touchPosition))
{
SetShowing(false);
}
}
}
// Check for rect
private static bool IsInRect(RectTransform rectTransform, Vector2 touchPosition)
{
// No main camera or rect
Camera cam = Camera.main;
if (cam == null || rectTransform == null)
{
return false;
}
// Check mouse position screen point
return RectTransformUtility.RectangleContainsScreenPoint(rectTransform, touchPosition, cam);
}
#endif
#region LOAD
/// <summary>
/// Load dropdown with specified options
/// </summary>
/// <param name="newOptions">The options to be used</param>
public void LoadDropdown(string[] newOptions)
{
// Get options
_options = newOptions;
// Disable all previous cells
foreach (var cell in _cells)
{
cell.gameObject.SetActive(false);
}
// Setup if needed, or log error
FindCellPrefab();
if (_dropdownListCellPrefab == null)
{
VLog.W($"Cannot load {gameObject.name} without a cell prefab");
return;
}
// Iterate all options
float height = 0f;
int total = _options == null ? 0 : _options.Length;
for (int c = 0; c < total; c++)
{
// Get existing cell if possible
Toggle cell = c < _cells.Count ? _cells[c] : null;
// Instantiate if needed
if (cell == null)
{
// Instantiate
cell = Instantiate(_dropdownListCellPrefab.gameObject).GetComponent<Toggle>();
cell.name = $"{_dropdownListCellPrefab.gameObject.name}_CELL_{c:000}";
cell.transform.SetParent(_dropdownListScrollRect.content, false);
// Override cell
if (c < _cells.Count)
{
_cells[c] = cell;
}
// Add new cell
else
{
_cells.Add(cell);
}
}
// Enable & load
cell.gameObject.SetActive(true);
LoadCell(cell, c, _options[c], ref height);
}
// Set height to content of scrolldown list
_dropdownListScrollRect.content.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0f, height);
}
/// <summary>
/// Load a specific cell
/// </summary>
/// <param name="index">Cell index</param>
/// <returns>Height of cell</returns>
protected virtual void LoadCell(Toggle cell, int index, string option, ref float y)
{
// Apply name to cell
Text cellText = cell.GetComponentInChildren<Text>();
if (cellText != null)
{
cellText.text = option;
}
// Apply callback to cell
cell.onValueChanged.RemoveAllListeners();
cell.isOn = false;
cell.onValueChanged.AddListener((isSelected) => OnCellClick(index, isSelected));
// Apply width to cell
RectTransform cellRect = cell.GetComponent<RectTransform>();
cellRect.anchorMin = new Vector2(0f, 1f);
cellRect.anchorMax = new Vector2(1f, 1f);
cellRect.pivot = new Vector2(0.5f, 1f);
cellRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, _dropdownListScrollRect.content.rect.width);
cellRect.anchoredPosition = new Vector2(0f, -y);
// Apply height
float height = cellRect.rect.height;
if (cellText != null)
{
float textMargin = Mathf.Max(0f, height - cellText.rectTransform.rect.height);
height = Mathf.CeilToInt(cellText.preferredHeight + _dropdownCellTextPadding + textMargin);
cellRect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);
}
// Add new height
y += height;
}
#endregion
#region SELECTION
/// <summary>
/// Select an item in the dropdown list
/// </summary>
/// <param name="newIndex">The option index to be selected</param>
public void SelectOption(int newIndex)
{
// Ignore if same
if (newIndex == SelectedOptionIndex)
{
return;
}
// Apply new index
_selectedOptionIndex = newIndex;
// Get option text
string optionText = SelectedOption;
// Apply to button
Text buttonText = _dropdownToggle.GetComponentInChildren<Text>();
if (buttonText != null)
{
if (string.IsNullOrEmpty(optionText))
{
buttonText.text = DropdownToggleUnselectedText;
}
else
{
buttonText.text = optionText;
}
}
// Adjust cells
int total = _cells == null ? 0 : _cells.Count;
for (int i = 0; i < total; i++)
{
_cells[i].isOn = i == SelectedOptionIndex;
_cells[i].interactable = i != SelectedOptionIndex;
}
// Call event
OnOptionSelected?.Invoke(optionText);
OnIndexSelected?.Invoke(SelectedOptionIndex);
// Selected
if (IsShowing)
{
SetShowing(false);
}
}
/// <summary>
/// Select option by name
/// </summary>
/// <param name="option">The option to be selected</param>
public void SelectOption(string option) => SelectOption(GetOptionIndex(option));
/// <summary>
/// When a cell is clicked, select a specific option
/// </summary>
/// <param name="index">Cell index clicked</param>
/// <param name="toSelected">Whether cell was selected or unselected</param>
private void OnCellClick(int index, bool toSelected)
{
if (toSelected && index != SelectedOptionIndex)
{
SelectOption(index);
}
}
/// <summary>
/// A method for obtaining the index of a dropdown option string.
/// </summary>
/// <param name="option">Accepts an option text string that matches a loaded text option.</param>
/// <returns>Returns the index of the provided option string</returns>
public int GetOptionIndex(string option)
{
if (_options != null)
{
for (int o = 0; o < _options.Length; o++)
{
if (string.Equals(_options[o], option))
{
return o;
}
}
}
return -1;
}
#endregion
#region APPEARANCE
/// <summary>
/// Show or hide the popup
/// </summary>
/// <param name="toShowing">The option index to be selected</param>
public void SetShowing(bool toShowing)
{
if (toShowing && (Options == null || Options.Length <= 0))
{
Debug.Log("SimpleDropdownList - Cannot show without any options");
return;
}
IsShowing = toShowing;
_dropdownToggle.isOn = IsShowing;
if (_dropdownListPopup != null)
{
_dropdownListPopup.alpha = toShowing ? 1f : 0f;
_dropdownListPopup.interactable = toShowing;
_dropdownListPopup.blocksRaycasts = toShowing;
}
if (_dropdownButtonArrowImage != null)
{
_dropdownButtonArrowImage.localRotation = Quaternion.Euler(0f, 0f, IsShowing ? 0f : 180f);
}
}
/// <summary>
/// Called when toggle button is clicked
/// </summary>
private void OnToggleClick(bool toToggle)
{
if (toToggle != IsShowing)
{
SetShowing(toToggle);
}
}
#endregion
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d02d4f2f4a56a5c4bb1f95bc6a8f3a0c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,90 @@
/*
* 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 Meta.WitAi.TTS;
using Meta.WitAi.TTS.Data;
using Meta.WitAi.TTS.Integrations;
using UnityEngine;
using UnityEngine.UI;
namespace Meta.Voice.Samples.TTSVoices
{
public class TTSCacheToggle : MonoBehaviour
{
// UI references
[SerializeField] private TTSDiskCache _diskCache;
[SerializeField] private Text _cacheLabel;
[SerializeField] private Button _button;
// Current disk cache location
private TTSDiskCacheLocation _cacheLocation = (TTSDiskCacheLocation) (-1);
// Add listeners
private void OnEnable()
{
// Obtain disk cache if possible
if (_diskCache == null)
{
_diskCache = GameObject.FindObjectOfType<TTSDiskCache>();
}
// Reset location text
RefreshLocation();
_button.onClick.AddListener(ToggleCache);
}
// Current disk cache location
private TTSDiskCacheLocation GetCurrentCacheLocation() => _diskCache == null ? TTSDiskCacheLocation.Stream : _diskCache.DiskCacheDefaultSettings.DiskCacheLocation;
// Check for changes
private void Update()
{
if (_cacheLocation != GetCurrentCacheLocation())
{
RefreshLocation();
}
}
// Refresh location & button text
private void RefreshLocation()
{
_cacheLocation = GetCurrentCacheLocation();
_cacheLabel.text = $"Disk Cache: {_cacheLocation}";
}
// Remove listeners
private void OnDisable()
{
_button.onClick.RemoveListener(ToggleCache);
}
// Toggle cache
public void ToggleCache()
{
// Toggle to next option
TTSDiskCacheLocation cacheLocation = GetCurrentCacheLocation();
switch (cacheLocation)
{
case TTSDiskCacheLocation.Stream:
cacheLocation = TTSDiskCacheLocation.Temporary;
break;
case TTSDiskCacheLocation.Temporary:
cacheLocation = TTSDiskCacheLocation.Persistent;
break;
case TTSDiskCacheLocation.Persistent:
cacheLocation = TTSDiskCacheLocation.Preload;
break;
default:
cacheLocation = TTSDiskCacheLocation.Stream;
break;
}
// Set next option
_diskCache.DiskCacheDefaultSettings.DiskCacheLocation = cacheLocation;
// Clear runtime cache
TTSService.Instance.UnloadAll();
// Refresh location
RefreshLocation();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0bb771ba1b3db6649a2bd0b5a31a37c9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,53 @@
/*
* 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;
using UnityEngine.UI;
using Meta.WitAi.TTS;
namespace Meta.Voice.Samples.TTSVoices
{
public class TTSErrorText : MonoBehaviour
{
// Label
[SerializeField] private Text _errorLabel;
// Current error response
private string _error;
// Reset on enable
private void OnEnable()
{
RefreshText();
}
// Add listeners
private void Update()
{
string invalidError = TTSService.Instance == null ? "No TTS Service Found" : TTSService.Instance.GetInvalidError();
if (!string.Equals(invalidError, _error))
{
_error = invalidError;
RefreshText();
}
}
// Refresh text
private void RefreshText()
{
if (string.IsNullOrEmpty(_error))
{
_errorLabel.text = string.Empty;
}
else
{
_errorLabel.text = $"Error: {_error}";
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 068bc7513e88e664c817d3597ab8e589
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,83 @@
/*
* 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 System.Collections.Generic;
using Meta.WitAi.Requests;
using Meta.WitAi.TTS;
using Meta.WitAi.TTS.Data;
using Meta.WitAi.TTS.Integrations;
using UnityEngine;
using UnityEngine.UI;
namespace Meta.Voice.Samples.TTSVoices
{
public class TTSFileToggle : MonoBehaviour
{
// UI references
[SerializeField] private TTSWit _service;
[SerializeField] private Button _button;
[SerializeField] private Text _label;
[SerializeField] private string _labelFormat = "File Type: {0}";
// Current audio file type
private TTSWitAudioType _fileType = (TTSWitAudioType) (-1);
private List<TTSWitAudioType> _fileTypes = new List<TTSWitAudioType>(Enum.GetValues(typeof(TTSWitAudioType)) as TTSWitAudioType[]);
// Add listeners
private void OnEnable()
{
if (_service == null)
{
_service = GameObject.FindObjectOfType<TTSWit>();
}
_button.onClick.AddListener(Toggle);
}
// Check for changes
private void Update()
{
if (_fileType != _service.RequestSettings.audioType)
{
Refresh();
}
}
// Remove listeners
private void OnDisable()
{
_button.onClick.RemoveListener(Toggle);
}
// Toggle cache
private void Toggle()
{
// Increment to next
int index = _fileTypes.IndexOf(_fileType);
index++;
if (index >= _fileTypes.Count)
{
index = 0;
}
// Apply file type
_service.RequestSettings.audioType = _fileTypes[index];
// Clear runtime cache
_service.UnloadAll();
// Refresh
Refresh();
}
// Refresh location & button text
private void Refresh()
{
_fileType = _service.RequestSettings.audioType;
_label.text = string.Format(_labelFormat, _fileType.ToString());
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1477d39e8c825744295e2e122d84ca82
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,150 @@
/*
* 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.Text;
using UnityEngine;
using Meta.WitAi;
namespace Meta.Voice.Samples.TTSVoices
{
/// <summary>
/// A demo script that uses two dropdown menus to adjust the
/// SSML tags of a TTSSpeaker.
/// </summary>
public class TTSSpeakerEffectSelect : TTSSpeakerObserver
{
[Header("Effect Settings")]
[SerializeField] [Tooltip("Dropdown used for character selection")]
private SimpleDropdownList _characterDropdown;
[SerializeField] [Tooltip("Dropdown used for environment selection")]
private SimpleDropdownList _environmentDropdown;
// Supported IDs
private const string NONE_ID = "NONE";
private static readonly string[] CHARACTER_IDS = new [] {NONE_ID, "CHIPMUNK", "MONSTER", "ROBOT", "DAEMON"};
private static readonly string[] ENVIRONMENT_IDS = new [] {NONE_ID, "REVERB", "ROOM", "PHONE", "PA", "CATHEDRAL"};
protected override void OnEnable()
{
base.OnEnable();
RefreshDropdowns();
_characterDropdown.OnIndexSelected.AddListener(OnCharacterSelected);
_environmentDropdown.OnIndexSelected.AddListener(OnEnvironmentSelected);
}
protected override void OnDisable()
{
base.OnDisable();
_characterDropdown.OnIndexSelected.RemoveListener(OnCharacterSelected);
_environmentDropdown.OnIndexSelected.RemoveListener(OnEnvironmentSelected);
}
// Refresh dropdown using voice settings
private void RefreshDropdowns()
{
if (!Speaker)
{
VLog.W("No speaker found");
return;
}
// Refresh characters
RefreshDropdown("character", _characterDropdown, CHARACTER_IDS);
// Refresh environments
RefreshDropdown("environments", _environmentDropdown, ENVIRONMENT_IDS);
}
// Refresh a specific dropdown
private void RefreshDropdown(string id, SimpleDropdownList dropdown, string[] options)
{
if (!dropdown)
{
VLog.W($"No {id} dropdown found");
return;
}
if (options == null || options.Length == 0)
{
VLog.W($"No {id} options found");
return;
}
// Load dropdown & select first index
dropdown.LoadDropdown(options);
dropdown.SelectOption(0);
}
// Apply voice on option select
private void OnCharacterSelected(int newIndex)
{
RefreshSsml();
}
// Apply voice on option select
private void OnEnvironmentSelected(int newIndex)
{
RefreshSsml();
}
// Refresh speaker ssml
private void RefreshSsml()
{
if (!Speaker)
{
VLog.W("No speaker found");
return;
}
// Get SSMLs
StringBuilder prepend = new StringBuilder();
StringBuilder append = new StringBuilder();
// Add ssml tags
prepend.Append("<speak>");
append.Append("</speak>");
// Get character & environment ids
string characterId = _characterDropdown.SelectedOption;
if (string.Equals(characterId, NONE_ID))
{
characterId = null;
}
string environmentId = _environmentDropdown.SelectedOption;
if (string.Equals(environmentId, NONE_ID))
{
environmentId = null;
}
// Add sfx tag
bool hasCharacter = !string.IsNullOrEmpty(characterId);
bool hasEnvironment = !string.IsNullOrEmpty(environmentId);
if (hasCharacter || hasEnvironment)
{
// Add prefix & postfix
prepend.Append("<sfx");
append.Insert(0, "</sfx>");
// Add character
if (hasCharacter)
{
prepend.Append($" character=\"{characterId.ToLower()}\"");
}
// Add environment
if (hasEnvironment)
{
prepend.Append($" environment=\"{environmentId.ToLower()}\"");
}
// Finalize
prepend.Append(">");
}
// Set SSML
Speaker.PrependedText = prepend.ToString();
Speaker.AppendedText = append.ToString();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6048a14add38e0449b1e683cd42a6958
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,175 @@
/*
* 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 System.Collections;
using UnityEngine;
using UnityEngine.UI;
using Meta.WitAi.TTS.Utilities;
namespace Meta.Voice.Samples.TTSVoices
{
public class TTSSpeakerInput : MonoBehaviour
{
// Speaker
[SerializeField] private TTSSpeaker _speaker;
// Default input
[SerializeField] private InputField _input;
[SerializeField] private Button _stopButton;
[SerializeField] private Button _pauseButton;
[SerializeField] private Button _speakButton;
// Queue button that will not stop previous clip
[SerializeField] private Toggle _queueButton;
// Async toggle that will play a clip on completion
[SerializeField] private Toggle _asyncToggle;
[SerializeField] private AudioClip _asyncClip;
[SerializeField] private string _dateId = "[DATE]";
[SerializeField] private string[] _queuedText;
// States
private string _voice;
private bool _loading;
private bool _speaking;
private bool _paused;
// Add delegates
private void OnEnable()
{
RefreshStopButton();
RefreshPauseButton();
_stopButton.onClick.AddListener(StopClick);
_pauseButton.onClick.AddListener(PauseClick);
_speakButton.onClick.AddListener(SpeakClick);
}
// Stop click
private void StopClick() => _speaker.Stop();
// Pause click
private void PauseClick()
{
if (_speaker.IsPaused)
{
_speaker.Resume();
}
else
{
_speaker.Pause();
}
}
// Speak phrase click
private void SpeakClick()
{
// Speak phrase
string phrase = FormatText(_input.text);
bool queued = _queueButton != null && _queueButton.isOn;
bool async = _asyncToggle != null && _asyncToggle.isOn;
// Speak async
if (async)
{
StartCoroutine(SpeakAsync(phrase, queued));
}
// Speak queued
else if (queued)
{
_speaker.SpeakQueued(phrase);
}
// Speak
else
{
_speaker.Speak(phrase);
}
// Queue additional phrases
if (_queuedText != null && _queuedText.Length > 0 && queued)
{
foreach (var text in _queuedText)
{
_speaker.SpeakQueued(FormatText(text));
}
}
}
// Speak async
private IEnumerator SpeakAsync(string phrase, bool queued)
{
// Queue
if (queued)
{
yield return _speaker.SpeakQueuedAsync(new string[] { phrase });
}
// Default
else
{
yield return _speaker.SpeakAsync(phrase);
}
// Play complete clip
if (_asyncClip != null)
{
_speaker.AudioSource.PlayOneShot(_asyncClip);
}
}
// Format text with current datetime
private string FormatText(string text)
{
string result = text;
if (result.Contains(_dateId))
{
DateTime now = DateTime.Now;
string dateString = $"{now.ToLongDateString()} at {now.ToLongTimeString()}";
result = text.Replace(_dateId, dateString);
}
return result;
}
// Remove delegates
private void OnDisable()
{
_stopButton.onClick.RemoveListener(StopClick);
_speakButton.onClick.RemoveListener(SpeakClick);
}
// Preset text fields
private void Update()
{
// On preset voice id update
if (!string.Equals(_voice, _speaker.presetVoiceID))
{
_voice = _speaker.presetVoiceID;
_input.placeholder.GetComponent<Text>().text = $"Write something to say in {_voice}'s voice";
}
// On state changes
if (_loading != _speaker.IsLoading)
{
RefreshStopButton();
}
if (_speaking != _speaker.IsSpeaking)
{
RefreshStopButton();
}
if (_paused != _speaker.IsPaused)
{
RefreshPauseButton();
}
}
// Refresh interactable based on states
private void RefreshStopButton()
{
_loading = _speaker.IsLoading;
_speaking = _speaker.IsSpeaking;
_stopButton.interactable = _loading || _speaking;
}
// Refresh text based on pause state
private void RefreshPauseButton()
{
_paused = _speaker.IsPaused;
_pauseButton.GetComponentInChildren<Text>().text = _paused ? "Resume" : "Pause";
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e2a2f88982fbc6f41a28fbeeb848c631
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,152 @@
/*
* 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;
using Meta.WitAi.TTS.Data;
using Meta.WitAi.TTS.Utilities;
namespace Meta.Voice.Samples.TTSVoices
{
/// <summary>
/// A demo script that provides access to a TTSSpeaker
/// and overrides all TTSSpeaker callback events.
/// </summary>
public class TTSSpeakerObserver : MonoBehaviour
{
[Header("Speaker Settings")]
[SerializeField] [Tooltip("TTSSpeaker being observed, if left empty it will grab the speaker from the GameObject")]
private TTSSpeaker _speaker;
public TTSSpeaker Speaker => _speaker;
/// <summary>
/// Obtains speaker if not set
/// </summary>
protected virtual void Awake()
{
if (_speaker == null)
{
_speaker = gameObject.GetComponentInChildren<TTSSpeaker>();
}
}
/// <summary>
/// On enable, add all callbacks
/// </summary>
protected virtual void OnEnable()
{
if (_speaker == null)
{
return;
}
_speaker.Events.OnPlaybackQueueBegin.AddListener(OnPlaybackQueueBegin);
_speaker.Events.OnPlaybackQueueComplete.AddListener(OnPlaybackQueueComplete);
_speaker.Events.OnLoadBegin.AddListener(OnLoadBegin);
_speaker.Events.OnLoadAbort.AddListener(OnLoadAbort);
_speaker.Events.OnLoadFailed.AddListener(OnLoadFailed);
_speaker.Events.OnLoadSuccess.AddListener(OnLoadSuccess);
_speaker.Events.OnPlaybackReady.AddListener(OnPlaybackReady);
_speaker.Events.OnPlaybackStart.AddListener(OnPlaybackStart);
_speaker.Events.OnPlaybackCancelled.AddListener(OnPlaybackCancelled);
_speaker.Events.OnPlaybackComplete.AddListener(OnPlaybackComplete);
}
/// <summary>
/// On disable, remove all callbacks
/// </summary>
protected virtual void OnDisable()
{
if (_speaker == null)
{
return;
}
_speaker.Events.OnPlaybackQueueBegin.RemoveListener(OnPlaybackQueueBegin);
_speaker.Events.OnPlaybackQueueComplete.RemoveListener(OnPlaybackQueueComplete);
_speaker.Events.OnLoadBegin.RemoveListener(OnLoadBegin);
_speaker.Events.OnLoadAbort.RemoveListener(OnLoadAbort);
_speaker.Events.OnLoadFailed.RemoveListener(OnLoadFailed);
_speaker.Events.OnLoadSuccess.RemoveListener(OnLoadSuccess);
_speaker.Events.OnPlaybackReady.RemoveListener(OnPlaybackReady);
_speaker.Events.OnPlaybackStart.RemoveListener(OnPlaybackStart);
_speaker.Events.OnPlaybackCancelled.RemoveListener(OnPlaybackCancelled);
_speaker.Events.OnPlaybackComplete.RemoveListener(OnPlaybackComplete);
}
/// <summary>
/// Callback for queue begin
/// </summary>
protected virtual void OnPlaybackQueueBegin()
{
}
/// <summary>
/// Callback for queue completion
/// </summary>
protected virtual void OnPlaybackQueueComplete()
{
}
/// <summary>
/// Callback for load begin
/// </summary>
protected virtual void OnLoadBegin(TTSSpeaker speaker, TTSClipData clipData)
{
}
/// <summary>
/// Callback for load cancelation
/// </summary>
protected virtual void OnLoadAbort(TTSSpeaker speaker, TTSClipData clipData)
{
}
/// <summary>
/// Callback for load error
/// </summary>
protected virtual void OnLoadFailed(TTSSpeaker speaker, TTSClipData clipData, string error)
{
}
/// <summary>
/// Callback for load success
/// </summary>
protected virtual void OnLoadSuccess(TTSSpeaker speaker, TTSClipData clipData)
{
}
/// <summary>
/// Callback for playback is ready for a clip
/// </summary>
protected virtual void OnPlaybackReady(TTSSpeaker speaker, TTSClipData clipData)
{
}
/// <summary>
/// Callback for playback for a clip has begun
/// </summary>
protected virtual void OnPlaybackStart(TTSSpeaker speaker, TTSClipData clipData)
{
}
/// <summary>
/// Callback for playback for a clip has been canceled
/// </summary>
protected virtual void OnPlaybackCancelled(TTSSpeaker speaker, TTSClipData clipData, string reason)
{
}
/// <summary>
/// Callback for playback completion
/// </summary>
protected virtual void OnPlaybackComplete(TTSSpeaker speaker, TTSClipData clipData)
{
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 04b4aa12d54b5eb41b8666111dbe7e71
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,81 @@
/*
* 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.Text;
using UnityEngine;
using UnityEngine.UI;
using Meta.WitAi.TTS.Data;
using Meta.WitAi.TTS.Utilities;
namespace Meta.Voice.Samples.TTSVoices
{
/// <summary>
/// A simple script for providing clip information to a Text label
/// </summary>
public class TTSSpeakerStatusLabel : TTSSpeakerObserver
{
[SerializeField] private Text _label;
protected override void OnEnable()
{
base.OnEnable();
RefreshLabel();
}
protected override void OnLoadBegin(TTSSpeaker speaker, TTSClipData clipData)
{
RefreshLabel();
}
protected override void OnLoadAbort(TTSSpeaker speaker, TTSClipData clipData)
{
RefreshLabel();
}
protected override void OnLoadFailed(TTSSpeaker speaker, TTSClipData clipData, string error)
{
RefreshLabel();
}
protected override void OnLoadSuccess(TTSSpeaker speaker, TTSClipData clipData)
{
RefreshLabel();
}
protected override void OnPlaybackReady(TTSSpeaker speaker, TTSClipData clipData)
{
RefreshLabel();
}
protected override void OnPlaybackStart(TTSSpeaker speaker, TTSClipData clipData)
{
RefreshLabel();
}
protected override void OnPlaybackCancelled(TTSSpeaker speaker, TTSClipData clipData, string reason)
{
RefreshLabel();
}
protected override void OnPlaybackComplete(TTSSpeaker speaker, TTSClipData clipData)
{
RefreshLabel();
}
private void RefreshLabel()
{
StringBuilder status = new StringBuilder();
int count = 1;
if (Speaker.IsSpeaking)
{
status.Append($"Speaking[{count}]: '{Speaker.SpeakingClip.textToSpeak}'");
status.AppendLine("\n");
count++;
}
foreach (var clip in Speaker.QueuedClips)
{
status.Append($"{clip.loadState.ToString()}[{count}]: '{clip.textToSpeak}'");
status.AppendLine("\n");
count++;
}
_label.text = status.ToString();
_label.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, _label.preferredHeight);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 57fe967670cb74c419e8588c173b0583
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,91 @@
/*
* 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.Linq;
using UnityEngine;
using Meta.WitAi;
namespace Meta.Voice.Samples.TTSVoices
{
/// <summary>
/// A demo script that uses a dropdown menu to adjust the
/// voice setting id of a TTSSpeaker.
/// </summary>
public class TTSSpeakerVoiceSelect : TTSSpeakerObserver
{
[SerializeField] [Tooltip("Dropdown used for voice selection")]
private SimpleDropdownList _dropdown;
protected override void Awake()
{
base.Awake();
_dropdown.DropdownToggleUnselectedText = "CUSTOM";
}
protected override void OnEnable()
{
base.OnEnable();
RefreshDropdown();
_dropdown.OnOptionSelected.AddListener(OnOptionSelected);
}
protected override void OnDisable()
{
base.OnDisable();
_dropdown.OnOptionSelected.RemoveListener(OnOptionSelected);
}
// Fix voice selection if changed elsewhere
private void Update()
{
if (!string.Equals(Speaker?.VoiceSettings?.SettingsId, _dropdown.SelectedOption))
{
_dropdown.SelectOption(Speaker?.VoiceSettings?.SettingsId);
}
}
// Refresh dropdown using voice settings
private void RefreshDropdown()
{
if (!Speaker)
{
VLog.W("No speaker found");
return;
}
if (!Speaker.TTSService)
{
VLog.W("No speaker service found");
return;
}
if (!_dropdown)
{
VLog.W("No dropdown found");
return;
}
// Get all voice names & load dropdown
string[] voiceNames = Speaker.TTSService.GetAllPresetVoiceSettings()
.Select((voiceSetting) => voiceSetting.SettingsId).ToArray();
_dropdown.LoadDropdown(voiceNames);
// Get selected voice &
_dropdown.SelectOption(Speaker.presetVoiceID);
}
// Apply voice on option select
private void OnOptionSelected(string newOption)
{
if (!Speaker)
{
VLog.W("No speaker found");
return;
}
Speaker.presetVoiceID = newOption;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 34daf0baa6f344a4f9256495171ccec0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,84 @@
/*
* 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;
using UnityEngine.UI;
using Meta.WitAi.TTS.Integrations;
namespace Meta.WitAi.TTS.Samples
{
public class TTSStreamToggle : MonoBehaviour
{
// UI references
[SerializeField] private TTSWit _service;
[SerializeField] private Text _label;
[SerializeField] private Button _button;
// Current stream
private bool _streamEnabled = true;
// Add listeners
private void OnEnable()
{
// Obtain disk cache if possible
if (_service == null)
{
_service = GameObject.FindObjectOfType<TTSWit>();
}
// Log for missing service
if (_service == null)
{
VLog.E("TTS Stream Toggle - Cannot work without a TTSWit reference");
}
// Reset
RefreshStreaming();
_button.onClick.AddListener(ToggleStreaming);
}
// Remove listeners
private void OnDisable()
{
_button.onClick.RemoveListener(ToggleStreaming);
}
// Refresh location & button text
private void RefreshStreaming()
{
_streamEnabled = GetStreaming();
_label.text = $"Streaming: {(_streamEnabled ? "ON" : "OFF")}";
}
// Toggle streaming
public void ToggleStreaming()
{
SetStreaming(!_streamEnabled);
RefreshStreaming();
}
// Get streaming option from service
private bool GetStreaming()
{
return _service && _service.RequestSettings.audioStream;
}
// Set streaming option to
private void SetStreaming(bool toStreaming)
{
if (_service != null)
{
_service.RequestSettings.audioStream = toStreaming;
_service.UnloadAll();
}
}
// Update if changed externally
private void Update()
{
if (_streamEnabled != GetStreaming())
{
RefreshStreaming();
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c780cd978be73ed43909c99f5fbcee4e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
Welcome to Voice SDK Text-To-Speech!
The following are phrases to be auto-loaded.
Hi, how are you?
I am great! Thank you for asking!
Would you mind repeating that?
I actually cannot hear you right now.
Hmmm
Well that is interesting!
My favorite color is green.
My favorite color is purple.
Sentence one begins with a few words and then ends with an ellipsis... Does sentence two start with two spaces and end with a question mark? Sentence three also starts with two spaces, has a comma; has a semicolon and ends with two exclamation points!! A sentence with a semicolon; may be used as well.
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7bc5942879ad5394b88ffcc2db2f52f3
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,453 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ae5a46bda3295124c99b0e6537ac7252, type: 3}
m_Name: TTS Voices - WitConfiguration
m_EditorClassIdentifier:
_clientAccessToken: HOKEABS7HPIQVSRSVWRPTTV75TQJ5QBP
_appInfo:
name: Built-in Models
id: voiceSDK_en
lang: en
isPrivate: 0
createdAt:
trainingStatus: 0
lastTrainDuration: 0
lastTrainedAt:
nextTrainAt:
intents:
- id: 897504424223811
name: wit$add_time_timer
entities: []
- id: 541438527164499
name: wit$add_to_playlist
entities: []
- id: 887283025240109
name: wit$cancel
entities: []
- id: 829935924385746
name: wit$check_weather_condition
entities: []
- id: 306952631193690
name: wit$confirmation
entities: []
- id: 377154377139380
name: wit$create_alarm
entities: []
- id: 418752679692656
name: wit$create_playlist
entities: []
- id: 365611011710102
name: wit$create_timer
entities: []
- id: 1033582527390432
name: wit$decrease_volume
entities: []
- id: 883987129203457
name: wit$delete_alarm
entities: []
- id: 247929240550715
name: wit$delete_playlist
entities: []
- id: 557555652118025
name: wit$delete_timer
entities: []
- id: 421700242885150
name: wit$dislike_music
entities: []
- id: 270102601621744
name: wit$fast_forward_track
entities: []
- id: 387498056115658
name: wit$get_alarms
entities: []
- id: 415840899887272
name: wit$get_date
entities: []
- id: 438703477461413
name: wit$get_sunrise
entities: []
- id: 375415767405106
name: wit$get_sunset
entities: []
- id: 4289162121138059
name: wit$get_temperature
entities: []
- id: 232518205474455
name: wit$get_time
entities: []
- id: 893990681247881
name: wit$get_time_until_date
entities: []
- id: 393845445654783
name: wit$get_timer
entities: []
- id: 549084829680351
name: wit$get_track_info
entities: []
- id: 3011049075798095
name: wit$get_weather
entities: []
- id: 1014318852665058
name: wit$go_back
entities: []
- id: 1031968647622673
name: wit$go_forward
entities: []
- id: 284911926808943
name: wit$increase_volume
entities: []
- id: 547658879873191
name: wit$like_music
entities: []
- id: 236590765151252
name: wit$loop_music
entities: []
- id: 4404756796280183
name: wit$negation
entities: []
- id: 4432284356859008
name: wit$nevermind
entities: []
- id: 831865090860258
name: wit$open_resource
entities: []
- id: 3014340998807022
name: wit$pause
entities: []
- id: 162448539383689
name: wit$pause_music
entities: []
- id: 629110521422335
name: wit$pause_timer
entities: []
- id: 1749588415235689
name: wit$play
entities: []
- id: 866056607377214
name: wit$play_music
entities: []
- id: 258248752970902
name: wit$play_podcast
entities: []
- id: 1030753921087273
name: wit$previous_track
entities: []
- id: 3112795525710499
name: wit$remove_from_playlist
entities: []
- id: 1641652012695476
name: wit$repeat_response
entities: []
- id: 391429655722707
name: wit$replay_track
entities: []
- id: 407662237413103
name: wit$resume
entities: []
- id: 658111892259804
name: wit$resume_music
entities: []
- id: 229892845779856
name: wit$resume_timer
entities: []
- id: 252614883454919
name: wit$rewind_track
entities: []
- id: 4540198562705611
name: wit$select_item
entities: []
- id: 2081412638678468
name: wit$share
entities: []
- id: 588748799212186
name: wit$shuffle_playlist
entities: []
- id: 917880522495837
name: wit$silence_alarm
entities: []
- id: 329368558953931
name: wit$skip_track
entities: []
- id: 2842638329380270
name: wit$snooze_alarm
entities: []
- id: 411892023684057
name: wit$stop
entities: []
- id: 238496474960073
name: wit$stop_music
entities: []
- id: 151481930517141
name: wit$subtract_time_timer
entities: []
- id: 620928052622542
name: wit$unloop_music
entities: []
- id: 1315332902220652
name: wit$unshuffle_playlist
entities: []
entities:
- name: wit$amount_of_money
id: 535a8110-2ea7-414f-a024-cf928b076d17
lookups: []
roles:
- name: amount_of_money
id: 388070769579971
keywords: []
- name: wit$datetime
id: 535a810f-8911-4bfe-976a-6e3c193f1251
lookups: []
roles:
- name: datetime
id: 457759871937748
keywords: []
- name: wit$distance
id: 535a80ff-e693-40c1-b67e-6f3e8e7144b8
lookups: []
roles:
- name: distance
id: 376395644039832
keywords: []
- name: wit$duration
id: 535a80fb-4be9-4991-a48e-8b2ca4ef6e54
lookups: []
roles:
- name: duration
id: 4245444588888025
keywords: []
- name: wit$email
id: 535a8107-7041-417d-b500-670b30d5267e
lookups: []
roles:
- name: email
id: 990197371827121
keywords: []
- name: wit$location
id: 535a80ff-6399-4653-8b2a-c770dd014965
lookups: []
roles:
- name: location
id: 699151467676773
keywords: []
- name: wit$phone_number
id: 535a810c-3885-41fe-a36f-3adfff96d72c
lookups: []
roles:
- name: phone_number
id: 535400004231868
keywords: []
- name: wit$quantity
id: 53d850ab-b009-4da5-9201-180aa916c5d4
lookups: []
roles:
- name: quantity
id: 390632932585329
keywords: []
- name: wit$temperature
id: 535a80f3-766b-49e7-bfb9-f4dedafc10aa
lookups: []
roles:
- name: temperature
id: 603855104116898
keywords: []
- name: wit$url
id: 535a80e6-23ec-43de-9c60-ed1d7f450157
lookups: []
roles:
- name: url
id: 2978877842431482
keywords: []
- name: wit$volume
id: 5a0cd7ec-754d-4ad5-abfa-413275a5f674
lookups: []
roles:
- name: volume
id: 358779385927032
keywords: []
traits:
- name: wit$bye
id: 5900cc2e-09ed-4764-800c-11e7566acfac
values:
- id: 955a38ae-f188-46ba-ab6d-4988c5a4bea6
value: true
- name: wit$greetings
id: 5900cc2d-41b7-45b2-b21f-b950d3ae3c5c
values:
- id: 547401529279585
value: true
- name: wit$sentiment
id: 5ac2b50a-44e4-466e-9d49-bad6bd40092c
values:
- id: 561371444570330
value: negative
- id: 1621429681354257
value: neutral
- id: 2522989351346070
value: positive
- name: wit$thanks
id: 5900cc2d-867c-4bf0-beb6-ef6e6bf45ca5
values:
- id: e5cce196-9948-420c-a9fb-9c2fd201adaf
value: true
voices:
- name: Cael
locale: en_US
gender: male
styles:
- default
- soft
- formal
- fast
- projected
- name: Cam
locale: en_US
gender: male
styles:
- default
- soft
- formal
- fast
- projected
- name: Carl
locale: en_US
gender: male
styles:
- default
- soft
- formal
- fast
- projected
- name: Charlie
locale: en_US
gender: male
styles:
- default
- soft
- fast
- projected
- name: Cody
locale: en_US
gender: male
styles:
- default
- soft
- formal
- fast
- projected
- name: Connor
locale: en_US
gender: male
styles:
- default
- soft
- formal
- fast
- projected
- name: Cooper
locale: en_US
gender: male
styles:
- default
- soft
- formal
- fast
- projected
- name: Prospector
locale: en_US
gender: male
styles:
- default
- name: Railey
locale: en_US
gender: female
styles:
- default
- soft
- formal
- fast
- projected
- name: Rebecca
locale: en_US
gender: female
styles:
- default
- soft
- formal
- fast
- projected
- name: Remi
locale: en_US
gender: female
styles:
- default
- soft
- formal
- fast
- projected
- name: Rubie
locale: en_US
gender: female
styles:
- default
- soft
- formal
- fast
- projected
- name: Vampire
locale: en_US
gender: male
styles:
- default
- soft
- formal
- fast
- projected
- name: Colin
locale: en_CA
gender: male
styles:
- default
- soft
- formal
- fast
- projected
- name: Rosie
locale: en_CA
gender: female
styles:
- default
- soft
- formal
- fast
- projected
composer:
canvases: []
_configurationId: d53421ff-aaf8-437f-b97e-262af416342e
timeoutMS: 10000
endpointConfiguration:
_uriScheme:
_authority:
_port: 0
_witApiVersion:
_message:
_speech:
_dictation:
_synthesize:
_event:
_converse:
isDemoOnly: 1
useConduit: 0
_manifestLocalPath: ConduitManifest-c1726bc0-a27c-4902-985d-93548a4a5a51.json
excludedAssemblies:
- Oculus.Voice.Demo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
- Meta.WitAi.Samples, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
relaxedResolution: 0
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6329e25e1005d4845b580a523e588979
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e99baad8337e84a4f93e76c76b8ce49b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: