Delphi XE5 Android Text to Speech example in CodeCentral

by Sep 29, 2013

Jeff Overcash, TeamB member and the maintainer of the InterBase Express Components (IBX) for the past 13.5 years, has created a Delphi wrapper unit for Android text to speech functionality.  Jeff has also created a simple demo example that allows you to input some text into a TMemo and hear the text spoken on your Android device.  In a comment on the Delphi XE5 Android API Documentation forum, Jeff said he looked at the Java API source code to create the Delphi Text To Speech (TTS) unit.  He also mentioned an Android text to speech tutorial article that helped him –

The Delphi XE5 Android Text to Speech (TTS) API wrapper unit, Androidapi.JNI.TTS.pas, is included in the example Jeff has uploaded to CodeCentral –  The code that takes the text in the TMemo component and sends it to the Android TTS API is:

   text := StringToJString(Memo1.Lines.Text);
tts.speak(text, TJTextToSpeech.JavaClass.QUEUE_FLUSH, nil);

Thank you Jeff for showing everyone how they can call Android API functionality from Dephi XE5. With Delphi XE5 you can always get to any OS APIs using the OCClass bridge (for iOS) and JavaClass bridge (for Android). The RTL contains a number of units that provide Delphi interfaces to iOS frameworks written in Objective-C. These units are scoped with iOSapi and are found in the /source/rtl/ios directory of your product installation. For Android, Delphi also includes a number of units for the interfaces to Android APIs with the unit name scope of Androidapi and are found int he /source/rtl/android directory of your installation.

Another simple example that shows you how to use the Objective-C bridge (OCClass) and Java Bridge (JavaClass) to call into the OS is the DeviceInfo mobile code snippet you can find as part of the install at C:\Users\Public\Documents\RAD Studio\12.0\Samples\MobileCodeSnippets\DeviceInfo.