Skip to content

Instantly share code, notes, and snippets.

@jimfaster
Created August 11, 2025 14:00
Show Gist options
  • Select an option

  • Save jimfaster/cd412ec147ad52523982d254e13458ce to your computer and use it in GitHub Desktop.

Select an option

Save jimfaster/cd412ec147ad52523982d254e13458ce to your computer and use it in GitHub Desktop.
Mind map for YouTube video: Full Workshop: Realtime Voice AI — Mark Backman, Daily

Full Workshop: Realtime Voice AI — Mark Backman, Daily

TL;DR This workshop introduces Pipecat, an open-source Python framework by Daily for building real-time voice and AI multimodal agents. It highlights the challenges of real-time voice AI, emphasizing the need for natural, fast, and conversational interactions with a target latency of 800ms. The core of Pipecat is its flexible "multimedia pipeline" architecture, allowing developers to plug-and-play various services like STT, TTS, and LLMs (e.g., Google's Gemini Live, OpenAI, AWS Nova Sonic). Gemini Live simplifies the pipeline by integrating transcription, LLM, and text-to-speech into one service. The workshop covers practical aspects like transport choices (WebRTC for client-server, WebSockets for server-server), Voice Activity Detection (VAD) using Silero for accurate turn-taking, and advanced concepts like dynamic context management and semantic end-of-turn detection. Pipecat's modularity and orchestration capabilities enable complex setups like parallel pipelines and robust error handling, making it suitable for production-grade voice AI applications.


Information Mind Map

🧠 Full Workshop: Realtime Voice AI with Pipecat & Gemini

🎯 Workshop Overview & Goal

  • Host: Mark Backman (Daily) with Alles, Quinn, Nina, Verun (Daily), and Philip (Google DeepMind).
  • Objective: Hands-on workshop to build a voice bot.
  • Time: ~78 minutes.
  • Prerequisite Check:
    • Real-time streaming data requires a viable Wi-Fi connection. Tethering recommended if conference Wi-Fi is shaky.
    • Audience familiarity with Pipecat/Voice AI: Small.
    • Audience familiarity with real-time LLM/AI applications: Slightly larger.

💡 Understanding Real-time Voice AI

  • Core Challenge: Mimicking human communication (thousands of years of evolution).
  • User Expectations: High.
  • Key Requirements for Voice Bots:
    • Good Listener: Accurate and fast Speech-to-Text (STT).
    • Smart & Conversational: Powered by LLMs, connected to data stores.
    • Natural Sound: Realistic Text-to-Speech (TTS). Google Gemini Live praised for native audio dialogue.
    • Fast: End-to-end communication benchmark ~800 milliseconds (human level ~500ms).
  • Daily's Focus: Meeting these expectations through Pipecat.

🛠️ Pipecat: The Python Framework

  • Nature: Open-source Python framework for building voice and AI multimodal agents.
  • Developed by: Daily team.
  • Age: Just over a year old (officially March 2023, 13 months ago).
  • Core Concept: The Pipeline:
    • Definition: A multimedia pipeline of "processors" (boxes) that receive, stream, or modify data (audio, video).
    • Cascaded Model (Traditional):
      1. Transport (User Audio Input)
      2. Speech-to-Text Service (Transcribes audio to text)
      3. LLM (Processes text, generates response tokens)
      4. Text-to-Speech Service (Converts tokens to audio)
      5. Transport (Outputs audio to user)
    • Speech-to-Speech Models (e.g., Gemini Live):
      • Simplifies pipeline: LLM handles transcription, processing, and TTS in one box.
      • Still allows for utilities like audio recording.
      • Can optionally output text before speaking for parsing.
    • Value Proposition: Orchestration and abstractions for common utilities (recording, transcript outputs, artifact production, info manipulation).
    • Modularity: "Plug and Play" any service.
      • Example: Change LLM (Google, OpenAI, Llama, Anthropic, Bedrock, Grok), STT (Deepgram), TTS (Cartisia, 11 Labs, Rhyme).
      • Allows changing services without altering underlying application code.
    • Parallel Pipelines: Split branches for different logic or dynamic failover (e.g., Vendor A fails, switch to Vendor B). Can transfer contexts.

💻 Building a Voice Bot with Pipecat (Code Walkthrough)

  • Repo: daily-co/gemini-pipcat-workshop on GitHub.
  • Main File: gemini_bot.py (all Python).
  • Core Components in Code:
    • main function: Runs the bot, encapsulated in AIO HTTP session.
    • Daily Transport: WebRTC provider for audio input/output.
      • Configured with room URL, token (optional), params (input_enable, output_enable).
      • Integrates Silero VAD analyzer.
    • Context Aggregation:
      • Collects conversation turns (user & assistant) into a format LLMs can handle (default OpenAI format).
      • Less critical for speech-to-speech models like Gemini Live, which handle much of this internally.
    • GeminiMultimodalLiveLLMService: Pipecat class wrapping Gemini Live API.
      • System Instruction: Defines agent's persona/purpose (e.g., "helpful assistant").
      • Tools: Define functions for the LLM to call.
        • Uses function schema (universal for LLMs) translated to tool schema.
        • Example: fetch_weather, restaurant_recommendation (canned handlers).
    • Pipeline Definition: A tuple/list of processors (e.g., transport.input, llm, transport.output).
    • Events: Transport emits client connects/disconnects handlers.
      • Used to inject a context frame into Gemini to kick off the conversation (e.g., "hello").
    • Runner & Task: Boilerplate to execute the pipeline.

❓ Q&A and Advanced Topics

🌐 Transport Mechanisms

  • WebRTC: Recommended for client-server apps (browser/mobile to server).
    • Properties: Error correction, better audio quality.
    • Pipecat's small WebRTC transport offers free peer-to-peer communication (requires own TURN server).
  • WebSockets: Recommended for server-to-server (e.g., phone chatbots).
    • Pipecat has a Fast API server for WebSocket message exchange.
  • Phone Carriers: Pipecat supports various phone integrations.
    • WebSocket connection: Twilio, Telnix, Pivo, Exotel for media streams.
    • PSTN (Public Switched Telephone Network).
    • SIP: Offers superior call control, but more complicated.
  • Cold Starts: Agents need to start immediately; provisioning resources to avoid 20-second waits.

🗣️ Voice Activity Detection (VAD)

  • Purpose: Detects when a user starts speaking, ushers in user's turn, triggers interruptions.
  • Recommendation: Silero (open-source).
    • Extremely accurate and fast inference time (milliseconds).
    • Low CPU consumption (fraction of 1% of total cost).
    • Tunable for how long to hear speech before emitting event.
  • Noise Cancellation: VAD alone isn't enough.
    • Crisp (CR IP): Partner offering fantastic noise cancellation, removing ambient and human background noise from audio feed.

🧠 LLM Context & State Management

  • Challenge: Large context windows slow down LLMs. Function calls are still slow (need full JSON response).
  • Strategies for Accuracy & Latency:
    • Task-Oriented Chunking: Break conversations into discrete tasks (e.g., restaurant reservation steps). LLMs excel at following recent input.
    • Judicious Context Window Control:
      • Resetting: Remove irrelevant past context (e.g., date of birth verification).
      • Summarizing: Out-of-band LLM calls to compress context for very long conversations.
    • Gemini Live: Offers context management strategies like rolling/sliding windows and token caps.
    • Structured Data: Large JSON contexts can confuse LLMs, impacting accuracy.

🌍 Local vs. Cloud LLMs

  • Local LLMs: Massive latency benefits (cut out network round trips).
    • Good for simple, task-oriented bots (e.g., Llama locally).
    • Hosting providers like Modal offer good options for leasing GPU time.
  • Cloud LLMs: State-of-the-art models often run on-prem or in the cloud.

🗣️ Speech-to-Speech LLM Providers

  • Options in Pipecat: Gemini Multimodal Live, OpenAI Realtime, AWS Nova Sonic.
  • Latency: Fantastic for all providers.
  • Emerging Field: Each has strengths and weaknesses.
  • System Instruction: Not uniformly handled across providers (OpenAI flexible, Anthropic/Google require constructor-time instruction). Pipecat unifies this where possible.

🗣️ End-of-Turn Detection / Interruption

  • Problem: Bots speaking over humans (VAD timeout is a simple stop-speaking algorithm).
  • Emerging Solution: Semantic End-of-Turn models.
    • Analyze speech filler words, pauses, intonation (audio realm) and context (text realm).
    • Pipecat's smart-turn model (GitHub): Native audio-in classifier outputs complete/incomplete.
    • Allows dynamic adjustment of VAD timeout (e.g., extend timeout if incomplete).
  • Status: Very much an unsolved problem, but rapid progress expected.

📝 TTS Word & Timestamp Synchronization

  • Feature: Pipecat leverages TTS providers (Cartisia, 11 Labs, Rhyme) that output word/timestamp alignment pairs.
  • Mechanism: TTS services output audio stream and text stream (TTS text frames).
  • Client Integration: Client SDKs can observe these text frames to synchronize word-by-word output with audio.

📊 Pipecat in Production & Ecosystem

  • Production Use: Used by very large companies, serves hundreds of thousands of calls/day.
  • Contributors: Nvidia, AWS, OpenAI, Google.
  • Client SDKs: Android, iOS, JavaScript, React, C++.
  • Evaluation: Release Eval bots (bot talking to bot) for end-to-end testing of services (Gemini Live, Cartisia, Deepgram, etc.).

🎮 Demo: Word Wrangler

  • Concept: A game like Catchphrase, where a human describes a word and an AI agent guesses it.
  • Implementation: Uses two Gemini Live agents in the same call with a parallel pipeline.
    • One agent is the host (gives questions).
    • The other is the guesser (AI player, only hears the user).
  • Availability:
    • Client-server version (React/Next.js project).
    • Phone-based version (Twilio).
  • Community: Discord available at pipcat.ai for questions and further exploration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment