Using Text to Speech in your Holographic App

Here is the 10th post of the series of “Holographic App Development Using Microsoft HoloLens“. In this article you will get some insight of enabling “Text to Speech” capabilities for your Holographic applications. You can place text to speech voices around your holograms to make your applications more interactive. You can achieve it very easily with the help of “TextToSpeech”  manager available with HoloLens Toolkit.
Follow the few simple steps to get it done.

Setup the Unity Project for Holographic App

Run a new instance of Unity 3D, create a new Unity Project, and Import the HoloToolkit for Unity by navigating from Import Package -> Custom Package

Import HoloToolkit

Download the HoloToolkit from here

Once the Package is initialized and loaded successfully, you would see the “HoloToolkit” option in the main Unity  menu bar. From the Configure option, apply the “HoloLens Scene Settings” and “HoloLens Project Settings” to make your project ready for holographic app.



Setting up the Holographic Project using HoloToolkit


If you are new into holographic app development with HoloLens, you can start looking at my series of post – Holographic App Development Using Microsoft HoloLens“.

Setting Up for Text to Speech Manager

Once the basic application setup is done follow the below steps
1. Add an Empty Object in the Object Hierarchy, and named it as “Audio Manager” (feel free to choose any other name)


Adding Audio Manager

2. Select the “Audio Manager” option from object hierarchy and from the right “Inspector” panel change the Spatial Blend” option from 2D to 3D.

3. Navigate to HoloToolkit -> Utilities -> Scripts, and Drag and Drop the “TextToSpeechManager” script over Audio manager as a component.
4. Drag the Audio Source and Attach it with the input parameter of Audio Source of “Text to Speech Manager Script


That’s all for setting up the Text to Speech Manager

Using the Text to Speech Manager

We have already setup the Project and the Text to Speech Manager, now time to use it.
1. Add a new C# Script file and add the following script for test TextToSpeechManager
public class CustomScript : MonoBehaviour {

	// Use this for initialization
	void Start () {
        var soundManager = GameObject.Find("Audio Manager");
        TextToSpeechManager textToSpeech = soundManager.GetComponent<TextToSpeechManager>;();
        textToSpeech.Voice = TextToSpeechVoice.Mark;
        textToSpeech.SpeakText("Welcome to the Holographic App ! You can use Gaze, Gesture and Voice Command to interact with it!");

	// Update is called once per frame
	void Update () {


 GameObject.Find() return the game object instance for the “Audio Manager” and in the next steps we are retrieving the Text To Speech Manager Components from the Audio manager.
2. Create another empty game object, say call  it as Root and attach this new “CustomScript” as a component.
That’s it. Build and Run the Application !!
You can place and attach the Audio Sources related with different Holograms and enable the text to speech command when user interact with those objects. There are different set of voices which you can select from the TextToSpeechVoice enumeration.
Hope this helps !

One thought on “Using Text to Speech in your Holographic App

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s