chapter ten
10 Building a voice-enabled AI chat application
This chapter covers
- The architecture of a voice AI pipeline
- Connecting MLX Whisper to Streamlit
- Refactoring the app into functions
- Adding a text fallback so the app also works with keyboard input
- Testing the full voice conversation loop
- Understanding what makes this application challenging and how to extend it
This is the chapter where everything comes together. In the previous chapters, you learned how to use the terminal, install Ollama, pull AI models, write Python, call the Ollama API, build web interfaces with Streamlit, and transcribe speech with MLX Whisper. In this chapter, you will combine all of those skills into a voice-enabled AI chat application: speak into your microphone, watch your words become text, and receive a streaming AI response, all running locally on your Mac, with complete privacy. You will continue working in the same my-ai-chatbot folder you used earlier; this chapter will add voice_chat.py in a ch10 subfolder, while voice_input.py file from chapter 9 remains in the project root.