The Teneo Android Chat app is an example Android chat app for Teneo. It uses the Teneo Android SDK and supports Google's Speech Recognition as well as Text to Speech. Conversations are displayed in a user-friendly chat interface.
The project demonstrates the following concepts:
You can find the source code of this project on Github.
This dependency in the app/build.gradle file enables the app to use the TIE SDK and communicate with the Teneo engine:
The onCreate method of the app initializes, among other things, the TieApiService
Within this app, a text can be sent to Teneo Engine anytime, with this helper method:
sendInputToTiE(String text, HashMap<String, String> params)
This project follows TIE SDK connectivity guidelines which are fully detailed in tie-api-example-android example.
This project implements Google's Android native Speech Recognizer, RecognizerIntent. The method launchGoogleVoice initializes RecognizerIntent with parameters such as Language, number of results, confidence scores, and is called from the microphone button's XML code in activity_chat.xml It also stops any Text to Speech playback before launching the Speech Recognizer.
Final Speech Recognition results are received at the onActivity callback, sent to Engine as text with consumeASRresults(int resultCode, Intent data).
The speech recognition language is customizable. In this project, the recognition language is set to UK English with asrIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en_GB").
Text to Speech (TTS) is implemented with Android's native TTS. The object googleTextToSpeech within the project is the center of voice synthesis, and is initialized, launched and released throughout the lifecycle.
In this project, the method saySomething(String text) speaks out loud the bot responses received from Teneo Engine. Localized TTS language is customizable. In this project, for example, TTS language is set to UK English with googleTextToSpeech.setLanguage(Locale.UK).
Chat UI is implemented in the MesageAdapter class. You may customize message bubble color, avatar, and sender in that class, if you wish.
In the project, user input from the ASR or the keyboard are posted into the chat window with addMessageToChatWindow(String messageText, String color, boolean isUser). Likewise, messages incoming from engine are also posted to the Chat Window.
Was this page helpful?