Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
Delphi

Delphi XE5 Android Text to Speech example in CodeCentral

Author: Joshua P7819

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 – http://www.androidhive.info/2012/01/android-text-to-speech-tutorial/.

Editor’s note: the site the writer originally linked to unfortunately appears to be defunct now. Here is an archived version of the article: https://web.archive.org/web/20171210142917/http://www.androidhive.info/2012/01/android-text-to-speech-tutorial/

The Delphi XE5 Android Text to Speech (TTS) API wrapper unit, Androidapi.JNI.TTS.pas, is included in the example uploaded to GitHub – https://github.com/jimmckeeth/FireMonkey-Android-Voice.  The code that takes the text in the TMemo component and sends it to the Android TTS API is:

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:UsersPublicDocumentsRAD Studio12.0SamplesMobileCodeSnippetsDeviceInfo.

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

4 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES