Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Voice Application Development for Android

You're reading from  Voice Application Development for Android

Product type Book
Published in Nov 2013
Publisher Packt
ISBN-13 9781783285297
Pages 134 pages
Edition 1st Edition
Languages

Table of Contents (19) Chapters

Voice Application Development for Android
Credits
Foreword
About the Authors
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface
1. Speech on Android Devices 2. Text-to-Speech Synthesis 3. Speech Recognition 4. Simple Voice Interactions 5. Form-filling Dialogs 6. Grammars for Dialog 7. Multilingual and Multimodal Dialogs 8. Dialogs with Virtual Personal Assistants 9. Taking it Further Afterword
Index

Chapter 3. Speech Recognition

Have you ever tapped through several menus and options on your device until you were able to do what you wanted? Have you ever wished you could just say some words and make it work? This chapter looks at Automatic Speech Recognition (ASR), the process that converts spoken words to written text. The topics covered are as follows:

  • The technology of speech recognition

  • Using Google speech recognition

  • Developing applications with the Google speech recognition API

By the end of this chapter, you should have a good understanding of the issues involved in using speech recognition in an app and should be able to develop simple apps using the Google speech API.

The technology of speech recognition


The following are the two main stages in speech recognition:

  • Signal processing: This stage involves capturing the words spoken into a microphone and using an analogue-to-digital converter (ADC) to translate it into digital data that can be processed by the computer. The ADC processes the digital data to remove noise and perform other processes such as echo cancellation in order to be able to extract those features that are relevant for speech recognition.

  • Speech recognition: The signal is split into minute segments that are matched against the phonemes of the language to be recognized. Phonemes are the smallest unit of speech, roughly equivalent to the letters of the alphabet. For example, the phonemes in the word cat are /k/, /æ/, and /t/. In English, for example, there are around 40 phonemes, depending on which variety of English is being spoken.

The most successful approach to speech recognition has been to model speech statistically so that the outcome...

Using Google speech recognition


Speech recognition services have been available on Android devices since Android 2.1 (API level 7). One place where recognition is available is via a microphone icon on the Android keyboard. Clicking on the microphone button activates the Google speech recognition service, as shown in the following screenshot. The red microphone and the textual prompt indicate that the system is expecting some speech:

If no speech is detected, a re-prompt dialog is generated, asking the user to try to speak again. Another possible situation is where no suitable match can be found for the user's spoken input. In this case, the screen displays the message No matches found. Finally, the message Connection problem is displayed when no internet connection is available.

The parameters of the on-board speech recognition services can be adjusted either through Settings | Language and input | Speech | Voice Search or, depending on the device, by clicking on the Tool icon at the top hand...

Developing applications with the Google speech recognition API


The components of the Google speech API (package android.speech) are documented at http://developer.android.com/reference/android/speech/package-summary.html. Interfaces and classes are listed here and further details can be obtained by clicking on them.

There are two ways in which speech recognition can be carried out on an Android device: based solely on a RecognizerIntent approach, or by creating an instance of SpeechRecognizer. The former provides an easy-to-program mechanism with which it is possible to create apps that use speech recognition by starting the Intent class and processing its results. The apps following this scheme will present a dialog providing feedback to the user on whether the ASR is ready, or about different errors during the recognition process. Using SpeechRecognizer provides developers with different notifications of recognition-related events, thus allowing a more fine-grained processing of the speech...

Summary


This chapter has shown how to use the Google speech API to implement speech recognition services, having checked that they are available on the device. The user is prompted to say some words and the results of the recognition, the recognized strings and their confidence scores, are displayed on the screen. The user can choose the language model for recognition and the maximum number of results to be retrieved. This functionality has been implemented following two different approaches in the ASRWithIntent and ASRWithLib apps.

The ASRWithIntent app is a basic easy-to-develop example in which all the code is contained in the same class. ASR is carried out using a RecognizerIntent class and there is an automatically generated dialog that provides feedback on whether the engine is listening or if there was any error.

The ASRWithLib app shows how to modularize and create a library for speech recognition that can be used in many apps. Instead of relying on the RecognizerIntent class only...

lock icon The rest of the chapter is locked
You have been reading a chapter from
Voice Application Development for Android
Published in: Nov 2013 Publisher: Packt ISBN-13: 9781783285297
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}