This application demonstrates how to work with a complex dependency in the Composable Architecture. It uses theSFSpeechRecognizer
API from theSpeech
framework to listen to audio on the device and live-transcribe it to the UI.
TheSFSpeechRecognizer
class is a complex dependency, and if we used it freely in our application we wouldn't be able to test any of that code. So, instead, we wrap the API in aSpeechClient
type that exposes asynchronous endpoints for accessing the underlyingSFSpeechRecognizer
class. Then we can use it in the reducer in an understandable way,andwe can write tests for the reducer.