Book Image

Voice Application Development for Android

Book Image

Voice Application Development for Android

Overview of this book

Speech technology has been around for some time now. However, it has only more recently captured the imagination of the general public with the advent of personal assistants on mobile devices that you can talk to in your own language. The potential of voice apps is huge as a novel and natural way to use mobile devices. Voice Application Development for Android is a practical, hands-on guide that provides you with a series of clear, step-by-step examples which will help you to build on the basic technologies and create more advanced and more engaging applications. With this book, you will learn how to create useful voice apps that you can deploy on your own Android device in no time at all. This book introduces you to the technologies behind voice application development in a clear and intuitive way. You will learn how to use open source software to develop apps that talk and that recognize your speech. Building on this, you will progress to developing more complex apps that can perform useful tasks, and you will learn how to develop a simple voice-based personal assistant that you can customize to suit your own needs. For more interesting information about the book, visit http://lsi.ugr.es/zoraida/androidspeechbook
Table of Contents (19 chapters)
Voice Application Development for Android
Credits
Foreword
About the Authors
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
Afterword
Index

Using Google text-to-speech synthesis


TTS has been available on Android devices since Android 1.6 (API Level 4).The components of the Google TTS API (package android.speech.tts) are documented at http://developer.android.com/reference/android/speech/tts/package-summary.html. Interfaces and classes are listed and further details can be obtained by clicking on these.

Starting the TTS engine

Starting the TTS engine involves creating an instance of the TextToSpeech class along with the method that will be executed when the TTS engine is initialized. Checking that TTS has been initialized is done through an interface called OnInitListener. If TTS initialization is complete, the method onInit is invoked.

The following lines of code create a TextToSpeech object that implements the onInit method of the onInitListener interface.

TextToSpeech tts = new TextToSpeech(this, new OnInitListener(){ 
    public void onInit(int status){ 
        if (status == TextToSpeech.SUCCESS) 
              speak("Hello...