Enables text to speech using the Windows 10 SpeechSynthesizer class.
SpeechSynthesizer generates speech as a SpeechSynthesisStream. This class converts that stream into a Unity AudioClip and plays the clip using the AudioSource you supply in the inspector. This allows you to position the voice as desired in 3D space. One recommended approach is to place the AudioSource on an empty GameObject that is a child of Main Camera and position it approximately 0.6 units above the camera. This orientation will sound similar to Cortana's speech in the OS.
상속: UnityEngine.MonoBehaviour
예제 #1
0
        private void Start()
        {
            // Make sure we have all the components in the scene we need.
            anchorManager = WorldAnchorManager.Instance;
            if (anchorManager == null)
            {
                Debug.LogError("This script expects that you have a WorldAnchorManager component in your scene.");
            }

            spatialMappingManager = SpatialMappingManager.Instance;
            if (spatialMappingManager == null)
            {
                Debug.LogError("This script expects that you have a SpatialMappingManager component in your scene.");
            }

            if (anchorManager != null && spatialMappingManager != null)
            {
                anchorManager.AttachAnchor(this.gameObject, SavedAnchorFriendlyName);
            }
            else
            {
                // If we don't have what we need to proceed, we may as well remove ourselves.
                Destroy(this);
            }

            ttsMgr = GetComponent <TextToSpeechManager>();
            if (ttsMgr == null)
            {
                Debug.LogError("TextToSpeechManager Required");
            }
        }
예제 #2
0
 private void Awake()
 {
     ttsManager             = this.GetComponent <TextToSpeechManager>();
     audioSource            = this.GetComponent <UnityEngine.AudioSource>();
     ttsManager.AudioSource = audioSource;
 }