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.