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
- 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.
- 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.
- 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):
Transport(User Audio Input)Speech-to-Text Service(Transcribes audio to text)LLM(Processes text, generates response tokens)Text-to-Speech Service(Converts tokens to audio)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.
- Repo:
daily-co/gemini-pipcat-workshopon GitHub. - Main File:
gemini_bot.py(all Python). - Core Components in Code:
mainfunction: Runs the bot, encapsulated inAIO HTTP session.DailyTransport: WebRTC provider for audio input/output.- Configured with
room URL,token(optional),params(input_enable,output_enable). - Integrates
Silero VAD analyzer.
- Configured with
Context Aggregation:- Collects conversation turns (user & assistant) into a format LLMs can handle (default
OpenAIformat). - Less critical for
speech-to-speechmodels like Gemini Live, which handle much of this internally.
- Collects conversation turns (user & assistant) into a format LLMs can handle (default
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 totool schema. - Example:
fetch_weather,restaurant_recommendation(canned handlers).
- Uses
Pipeline Definition: A tuple/list of processors (e.g.,transport.input,llm,transport.output).Events: Transport emitsclient connects/disconnectshandlers.- Used to inject a
context frameinto Gemini to kick off the conversation (e.g., "hello").
- Used to inject a
Runner&Task: Boilerplate to execute the pipeline.
- WebRTC: Recommended for client-server apps (browser/mobile to server).
- Properties: Error correction, better audio quality.
- Pipecat's
small WebRTC transportoffers 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.
- 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.
- 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 LLMs: Massive latency benefits (cut out network round trips).
- Good for simple, task-oriented bots (e.g., Llama locally).
- Hosting providers like
Modaloffer good options for leasing GPU time.
- Cloud LLMs: State-of-the-art models often run on-prem or in the cloud.
- 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.
- Problem: Bots speaking over humans (VAD timeout is a simple stop-speaking algorithm).
- Emerging Solution:
Semantic End-of-Turnmodels.- Analyze speech filler words, pauses, intonation (audio realm) and context (text realm).
- Pipecat's
smart-turnmodel (GitHub): Native audio-in classifier outputscomplete/incomplete. - Allows dynamic adjustment of VAD timeout (e.g., extend timeout if
incomplete).
- Status: Very much an unsolved problem, but rapid progress expected.
- 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.
- 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 Evalbots (bot talking to bot) for end-to-end testing of services (Gemini Live, Cartisia, Deepgram, etc.).
- Concept: A game like Catchphrase, where a human describes a word and an AI agent guesses it.
- Implementation: Uses two
Gemini Liveagents 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).
- One agent is the
- Availability:
- Client-server version (React/Next.js project).
- Phone-based version (Twilio).
- Community: Discord available at
pipcat.aifor questions and further exploration.