This project is an example iOS chat app for Teneo.
The project demonstrates the following concepts:
You can find the source code of this project on Github.
This project follows TIE SDK connectivity guidelines which are fully detailed in tie-api-client-ios SDK. This dependency in the Podfile file enables the app to use the TIE SDK and communicate with Teneo Engine.
The viewDidLoad method of the app initializes, among other things, the TieApiService and UI elements.
User inputs (texts) are sent to Teneo Engine with the helper method sendToTIE(String text, HashMap<String, String> params).
Additionally, user input received from the Speech Recognizer or the keyboard are posted to the Chat UI, and sent to Teneo Engine with this helper method consumeUserInput(userInput: String).
This project implements Apple's native iOS Speech Recognizer (ASR) with SFSpeechRecognizer. Behind other helper methods that validate app permissions and other conditions, sits the startAudioEngineAndNativeASR method, which performs two main tasks:
Tapping the microphone button silences any Text to Speech playback before launching the Speech Recognizer. Transcription results are received at the didFinishRecognition delegate method, posted as a message bubbles into the Chat UI and finally sent to the Teneo engine for processing.
Text to Speech (TTS) is implemented with Apple's iOS native AVSpeechSynthesizer. The object AVSpeechSynthesizer within the project is the center of voice synthesis, and is initialized, launched and released throughout the lifecycle. In this project, the method speakIOS12TTS(_ utterance:String) speaks the bot responses received from Teneo engine out loud.
The Chat UI and input bar are based on the MessageKit framework, but implemented as a self contained class inside this project. You can customize message bubble color, avatar, and sender in that class.
Was this page helpful?