AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
TextToSpeechOnTapTest.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using UnityEngine;
5 
6 namespace HoloToolkit.Unity.InputModule.Tests
7 {
11  public class TextToSpeechOnTapTest : MonoBehaviour, IInputClickHandler
12  {
13  private TextToSpeech textToSpeech;
14 
15  private void Awake()
16  {
17  textToSpeech = GetComponent<TextToSpeech>();
18  }
19 
20  public void OnInputClicked(InputClickedEventData eventData)
21  {
22  // If we have a text to speech manager on the target object, say something.
23  // This voice will appear to emanate from the object.
24  if (textToSpeech != null && eventData.PressType == InteractionSourcePressInfo.Select)
25  {
26  // Create message
27  var msg = string.Format(
28  "This is the {0} voice. It should sound like it's coming from the object you clicked. Feel free to walk around and listen from different angles.",
29  textToSpeech.Voice.ToString());
30 
31  // Speak message
32  textToSpeech.StartSpeaking(msg);
33 
34  eventData.Use(); // Mark the event as used, so it doesn't fall through to other handlers.
35  }
36  }
37  }
38 }
void StartSpeaking(string text)
Speaks the specified text using text-to-speech.
Enables text to speech using the Windows 10 SpeechSynthesizer class.
Definition: TextToSpeech.cs:54
Interface to implement to react to simple click input.
Tap Test for text to speech. This voice will appear to emanate from the object
InteractionSourcePressInfo PressType
Button type that initiated the event.
Describes an input event that involves a tap.
TextToSpeechVoice Voice
Gets or sets the voice that will be used to generate speech.
Definition: TextToSpeech.cs:68