Overview

1 Building Your Own AI — Getting Started

This opening chapter introduces the goal of the book: building a private, voice-enabled AI chat application that runs entirely on a Mac. The finished app will let you speak into a microphone, transcribe your words locally, send the text to a local large language model, and stream the AI’s response back in a browser-based chat interface. The project uses a Mac-first toolchain built around macOS, Terminal, Homebrew, VS Code, Python, Ollama, MLX Whisper, and Streamlit, with Python chosen because it is practical, beginner-friendly, and well supported in the local AI ecosystem.

The chapter explains why local AI is valuable, especially for privacy, voice privacy, freedom from subscriptions or changing cloud service rules, and deeper technical understanding. It contrasts local AI with cloud AI: cloud systems often provide the most powerful and current models, while local systems keep data on your machine, work offline, avoid ongoing fees, and give you more control. It also introduces large language models as systems trained on huge amounts of text that generate responses by predicting likely next words, while noting that they can produce confident but inaccurate answers. The required hardware and software are outlined as well, with Apple Silicon Macs preferred for performance, though Intel Macs can still be used with limitations.

The chapter then shifts from concepts to preparation by introducing the terminal as the essential interface for installing tools, running Python scripts, starting Ollama, and launching the final web app. It explains the difference between graphical interfaces and command-line interfaces, why developers rely on the command line for speed, precision, automation, portability, and AI-agent workflows, and how to open and customize Terminal on macOS. Finally, it teaches safe foundational commands for navigating and organizing files: pwd to show the current location, ls to list files, cd to move between folders, mkdir to create folders, and clear to clean the display. The chapter emphasizes that these basics are safe, error messages are normal feedback, and command-line confidence is the first practical step toward building the local AI application.

Cloud AI (right) sends your prompt across the internet to a hosted inference service, and your data may be stored on the company's servers. Local AI (left) keeps the prompt, the model, and the response inside your machine -- no network hop, no external server, no data leaving your control.
Overview of the voice chat application. Your Mac runs three pieces locally: a Streamlit web app in the browser captures your voice and renders the chat, MLX Whisper transcribes your speech to text, and Ollama runs the LLM that generates the streaming reply. The dashed boundary marks "your machine" -- nothing crosses it.
The GUI and the CLI offer different features, but both communicate with the computer's operating system. Clicking in the GUI and typing in the CLI ultimately reach the same destination.

Exercises

  1. Navigate your home directory. Open the terminal and use pwd to confirm you are in your home directory. Use ls to see all your folders. Navigate into Documents using cd Documents, list its contents, and return home using cd ~.
  2. Create a project structure. Starting from your home directory, create the following folder structure using only mkdir and cd:
  • After creating each folder, use pwd to verify your location and ls to confirm the folder was created.
  1. Explore hidden files. Run ls -la in your home directory. Count how many hidden files and folders (those starting with .) you see. Pick one and guess what it might be for.
  2. Speed comparison. Time yourself performing these tasks, first using Finder, then using the terminal:
    • Navigate to your Documents folder
    • Create a new folder called test_folder
    • Go inside the new folder
    • Go back to your home directory
    • Which method was faster? Write down your observations.
  3. Practice `clear` and `cd`. Navigate to three different folders (Desktop, Documents, Downloads), run ls in each one, then use clear to clean the screen. Finally, return home with cd ~ and run pwd to confirm.
  4. Reflect on your AI use. Think about the last three times you used a cloud AI service (ChatGPT, Gemini, Claude, or similar). For each interaction, consider: Did it contain private information? Did you need an internet connection? Could a local model have handled the task? Write down your answers. You will revisit this reflection after completing Chapter 4.

FAQ

What will I build in this book?You will build a voice-enabled local AI chat application on a Mac. The finished app lets you speak into your microphone, transcribes your voice on screen, sends the text to a local large language model, and displays a streaming AI response. Everything runs locally on your Mac using tools such as Ollama, MLX Whisper, Python, VS Code, and Streamlit.
Why should I run AI locally instead of using a hosted chatbot?Running AI locally gives you privacy, voice privacy, freedom, and understanding. Your prompts, voice recordings, transcripts, and AI responses stay on your machine instead of being sent to company servers. Local AI also works offline, avoids subscription fees, and helps you learn how AI systems actually work under the hood.
When should I use cloud AI instead of local AI?Cloud AI is useful when you need the strongest available model for complex reasoning, the content is not sensitive, you have a reliable internet connection, or you need the latest model updates or real-time information. Local AI is better when privacy, offline use, customization, learning, or avoiding subscriptions matter more.
What tools are used to build the local voice AI application?The project uses five key tools: Ollama to download, load, and serve local LLMs; MLX Whisper to transcribe speech locally on Apple Silicon; VS Code to write and organize code; Python as the programming language; and Streamlit to build the web-based chat interface.
What Mac hardware and software do I need?You need a recent Mac running macOS Ventura 13 or later, at least 8 GB of RAM, and at least 20 GB of free disk space. A stable internet connection is needed to download software and models, but after setup the AI can run offline. Apple Silicon Macs such as M1 or later are ideal, while Intel Macs can still follow along with slower performance and smaller models.
What is a large language model?A large language model, or LLM, is an AI model trained on enormous amounts of text. It learns patterns and relationships between words, then generates responses by predicting the most likely next word one piece at a time. LLMs can answer questions, summarize text, translate languages, write essays, and generate code, but they can also hallucinate, meaning they may produce confident-sounding but inaccurate answers.
What is the difference between a prompt, an API, and a terminal prompt?A prompt for an AI model is the input you give it, such as a question, instruction, transcript, or block of text. An API is a way for one program to talk to another program; later, Python code will use the Ollama API to send prompts to a local model. A terminal prompt, such as yourname@MacBook-Air ~ %, is the terminal’s way of saying it is ready for a command.
Why does this book teach the command line?The command line is essential because Ollama, Python, and Streamlit are controlled from the terminal. Developers use the CLI because it is fast, precise, automatable, and portable. It is also increasingly important because modern AI coding agents, such as Claude Code, Codex, and Gemini CLI, run in the terminal and can more easily read commands, execute them, and respond to text output.
How do I open Terminal on macOS?The recommended method is to press Command + Space to open Spotlight Search, type Terminal, and press Enter. You can also open Finder, go to Applications > Utilities, and double-click Terminal. Once open, you should see a prompt similar to yourname@MacBook-Air ~ %.
What are the essential terminal commands introduced in this chapter?The chapter introduces four essential navigation commands: pwd, which shows your current location; ls, which lists files and folders; cd, which changes directories; and mkdir, which creates a new folder. It also introduces clear to clean up the terminal display and Ctrl+C to cancel a running command.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build Applications with Local AI Models on a Mac ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build Applications with Local AI Models on a Mac ebook for free