TextToSpeech

TTS technology  reads aloud texts on computers, tablets and smartphones. It basically converts texts into spoken voice or audio by reading any string of text characters to form sentences.

Want to turn your words into human-like relatable voices? That is the power of TTS or Text to Speech Function.

Although this assistive technology was initially built for the visually impaired, it is now used to aid in learning languages. TTS helps children and foreign language learners in reading and correct speech pronunciation.

For your unity application, this TTS powered by OrukaUnity is geared up to fit for unity-based developments. It is a plug-in that allows the ease of using native text-to-speech feature for iOS and Android.

Features of OrukaUnity’s TTS include the following:

  • Volume, rate and pitch adjustments
  • Can switch TTS engines for voice language and settings for android

System Requirements include

  • iOS7 or higher
  • Android 1.6 or higher + TTS Engine

How to Use

  1. Demo for Easy TTS in Android and iOS

Sample Code  for EASY TTS using C#

  • public class DemoEasyTTS : MonoBehaviour { private string stringToEdit = “Test”; void OnGUI () { stringToEdit = GUI.TextField (new Rect (Screen.width/2-100, Screen.height/2-100, 200, 50), stringToEdit,200); if (GUI.Button (new Rect (Screen.width/2-50, Screen.height/2-20, 100, 40), “Speak”)) { EasyTTSUtil.SpeechAdd(stringToEdit); } } void Start(){ EasyTTSUtil.Initialize (EasyTTSUtil.UnitedStates); } void OnApplicationQuit() { EasyTTSUtil.Stop (); } }

The additional features allows to switch to other TTS engine in order to change option of Voice Setting and Language for the inputed text in Android which depends on the installed TTS engine.

  • EasyTTSUtil.Initialize(language, engine)
    • language – use the ISO 639-1 language code.
    • engine – is the package name of the installed TTS engine.​
  • EasyTTSUtil.GetEnginePkgArray() – allows access to the list of TTS names installed in the device
  • EasyTTSUtil.OpenTTSSetting() – opens a screen for voice setting of the device:

Sample Code for Android Additional Feature using C#

public class DemoEasyTTS_SelectEngine : MonoBehaviour
{
 
    private string stringToEdit = "Test";
    private bool selecting = false;
    private string engineName = "";
    private string enginePkg ="";
 
    void OnGUI ()
    {
        stringToEdit = GUI.TextField (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 50),
          stringToEdit, 200);
        if (GUI.Button (new Rect (Screen.width / 2 - 50, Screen.height / 2 - 20, 100, 40), "Speak")) {
            EasyTTSUtil.SpeechAdd (stringToEdit);
        }
        if (GUI.Button (new Rect (Screen.width / 2 - 50, Screen.height / 2 +100, 100, 40), "SelectList")) {
            selecting = true;
        }
        if (GUI.Button (new Rect (Screen.width / 2 - 50, Screen.height / 2 +300, 100, 40), "OpenTTSSetting")) {
            EasyTTSUtil.OpenTTSSetting ();
        }
 
        if (selecting) {
 
            string[] nameArray = EasyTTSUtil.GetEngineNameArray ();
 
            int selected = -1;
            selected = GUILayout.SelectionGrid (selected, nameArray, 1);
            if (selected != -1) {
 
                string[] pkgArray = EasyTTSUtil.GetEnginePkgArray ();
                enginePkg = pkgArray [selected];
                engineName = nameArray [selected];
                EasyTTSUtil.Initialize(EasyTTSUtil.UnitedStates,enginePkg);
                selecting = false;
            }
        }
        if (engineName == null) {
            engineName = "null";
        }
        GUI.TextField (new Rect (Screen.width / 2 - 50, Screen.height / 2 + 200, 100, 40), engineName);
 
    void Start(){
        EasyTTSUtil.Initialize (EasyTTSUtil.UnitedStates);
        engineName = EasyTTSUtil.GetDefaultEngineName ();
    }
 
    void OnApplicationQuit ()
    {
        EasyTTSUtil.Stop ();
    }
}

EasyTTSReadMe.txt is also provided with information on how to use the TTS package and detailed description.

Simple Text Style

SIMPLE TEXT STYLE is a complete substitute for default Unity fonts. It is designed to work similarly to the default Unity fonts but with extra stunning features to suit the needs for UI design. The use of this assets helps in the ease of the following:

Features

  • Can add projected text shadows
  • Can high quality outline
  • Can easily add Gradients to text
  • Can add Detail texture
  • Can tweak text resolution
  • Supports unity 4.3 sprite layer ordering
  • Can support undo, redo and multi-object editing

How to:

For Demo1 

This demo is about generating textStyleSetting and creating your own SimpleTextStyle

  1. Open Demo1.unity 
  2. In Unity, Navigate to InternalScript folder in Project section
  3. Right click on SimpleTextStyleSetting.cs and choose Generate “SimpleTextStyleSetting”
  4. Once generated, change the default generated filename (choose whatever filename you like that suits for your gameObject)

Now, you have your own generated SimpleTextStyle setting. You can now add your own SimpleTextStyle

  1. In your current scene, create UI>Text
  2. Put SimpleTextStyle to the GameObject (How to:)
    1. Drag the SimpleTextStyle script to the UI text you just created and you now have the script for your gameObject
    2. OR
    3. Navigate to Inspector, add a component below
    4. Choose Script and add the SimpleTextStyle script 
  3. For the setting, choose SimpleTextStyleSetting  (You can just drag the script and drop it to the Setting field in component)
  4. For the last step, tap the generated TextStyleSetting and modify some fields you want to edit whatever you edited (Font, style, size, colour, etc), the text on the UI will also take effect.

Easy right? 😉 

For Demo2 

This demo is about changing all style setting by theme or language setting.

  1. Open Demo2.unity 
  2. In Unity, Navigate to InternalScript folder in Project section
  3. Right click on SimpleTextStyleSettingLocator.cs and choose Generate “SimpleTextStyleSettingLocator”
  4. Once generated, tap the generated file and Navigate to Inspector
  5. As you can in our sample, we add HeaderEN as our Def Setting (You Can as well create your own SimpleTextStyleSetting from Demo1)
  6. Add the Key List size then the Setting List
  7. When changing the setting, call SimpleTextStyleSettingLocator.SetKey (string key) method

Okay cool! Easy right? 😉