forked from microsoft/MixedRealityToolkit-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TextToSpeechManagerTest.cs
53 lines (46 loc) · 1.74 KB
/
TextToSpeechManagerTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using UnityEngine;
using System.Collections;
using UnityEngine.VR.WSA.Input;
using UnityEngine.Windows.Speech;
using HoloToolkit.Unity;
using System;
public class TextToSpeechManagerTest : MonoBehaviour
{
private GestureRecognizer gestureRecognizer;
public TextToSpeechManager textToSpeechManager;
// Use this for initialization
void Start ()
{
// Set up a GestureRecognizer to detect Select gestures.
gestureRecognizer = new GestureRecognizer();
gestureRecognizer.TappedEvent += GestureRecognizer_TappedEvent;
gestureRecognizer.StartCapturingGestures();
}
private void GestureRecognizer_TappedEvent(InteractionSourceKind source, int tapCount, Ray headRay)
{
GazeManager gm = GazeManager.Instance;
if (gm.Hit)
{
// Get the target object
GameObject obj = gm.HitInfo.collider.gameObject;
// Try and get a TTS Manager
TextToSpeechManager tts = null;
if (obj != null)
{
tts = obj.GetComponent<TextToSpeechManager>();
}
// If we have a text to speech manager on the target object, say something.
// This voice will appear to emanate from the object.
if (tts != null)
{
tts.SpeakText("This voice should sound like it's coming from the object you clicked. Feel free to walk around and listen from different angles.");
}
}
}
public void SpeakTime()
{
// Say something using the text to speech manager on THIS test class (the "global" one).
// This voice will appear to follow the user.
textToSpeechManager.SpeakText("The time is " + DateTime.Now.ToString("t"));
}
}