AI Engineer World's Fair 2025
Full Workshop: Realtime Voice AI — Mark Backman, Daily
Read the talk
Building a realtime voice agent with Pipecat and Gemini Live
A voice bot needs more than speech generation: this workshop builds the audio pipeline, then explores interruptions, context, tools, testing, and selective routing between agents.
From a talk by Mark Backman and Aleix
Before you start: Basic Python, asynchronous functions, environment variables, and API credentials will help you follow the implementation; the audio and transport concepts are introduced along the way.
A voice bot needs a working connection
The assignment is straightforward: build a voice bot during the workshop. The first obstacle is the conference Wi-Fi. Mark Backman suggests tethering because realtime audio requires a sustained streaming connection, not just enough connectivity to send a short request. That dependency will soon interrupt the planned hands-on session.
Pipecat is the open-source Python framework used to assemble the bot. Daily builds it with community contributors; Aleix tentatively dates its official beginning to March 2024. Its scope includes voice and multimodal agents, where listening, reasoning, and output must operate as a continuous interaction.
A useful voice agent must listen accurately, converse intelligently, access databases or internet services, and sound natural. Mark singles out Gemini Live native audio dialogue for its voice quality. Speed is another requirement: Mark gives roughly 800 ms as a voice-response target, with a tentative human comparison around 500 ms. The completed slide specifies a median target below 800 ms; these are conversational design targets, not timings measured in this workshop.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Follow the audio through the processors
Pipecat organizes work as a multimedia pipeline. Each processor receives data and forwards the original data, modified data, or newly generated data to the next processor. In a conventional cascade, the transport receives microphone audio; speech-to-text produces a transcript; the LLM generates tokens; text-to-speech turns those tokens into audio; and the output transport delivers that audio to the listener.
Gemini Live combines several of those responsibilities in one service. Separate transcription, language generation, and speech-synthesis services are no longer necessary for the basic conversation. Recording audio, producing transcript artifacts, and manipulating data still require application orchestration. Fewer model services do not eliminate the pipeline around them.
| Architecture | Model path | Useful control point |
|---|---|---|
| Cascaded | Audio → STT → LLM → TTS | Text between services |
| Native speech-to-speech | Audio → multimodal service → audio | Surrounding processors |
| Native input, separate speech output | Audio → model text → TTS | Inspect text before speaking |
The workshop also discusses choosing text output from a native-audio service so an application can parse it before speech synthesis. Preserve that historical configuration when following the recording: current Gemini Live API documentation describes native-audio models using AUDIO responses with optional output transcription, which is distinct from selecting text-only responses for a separate TTS stage.
The processors also create substitution points. Deepgram can supply STT, while Google or OpenAI supplies the language model. Changing a service need not mean rewriting the surrounding application. A parallel pipeline adds branches for different processing paths; Mark describes using that structure to move from one vendor to another during a conversation and transfer context. Even a compact speech-to-speech implementation still needs these surrounding decisions about routing, artifacts, and service behavior.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Read the sample bot from configuration to first turn
The Pipecat + Gemini workshop repository provides the README quick start and sample bot files. Mark starts with repository orientation before opening the Python implementation. As the conference connection fails, the session shifts toward a code walkthrough; WebRTC is the transport used for the workshop bot.
The sample's main function runs inside an aiohttp session that can be shared by services. Its processing path uses Daily for transport, context aggregation around the model, Gemini Live for inference, and Daily again for output. A text LLM normally receives a discrete snapshot of the conversation on each request. The context aggregator collects user and assistant contributions and constructs that input. Gemini Live manages more conversational state internally, so aggregation here is particularly useful for tool calls and application management.
The Daily service takes a room, token, participant name, and transport properties. GeminiMultimodalLiveLLMService is the Pipecat wrapper shown for the Gemini Live API. The sample gives it two deliberately simple tools: a weather handler and a restaurant-recommendation handler. Both return canned local results, so their execution does not depend on another internet lookup.
Tool definitions can use a provider's native format, or Pipecat's common function schema. The latter describes the function once and lets the tool schema translate it into the provider-specific representation used by OpenAI, Anthropic, Gemini, Bedrock, or Groq. The service receives those tools together with a prompt explaining their availability. The sample also uses an OpenAI-style context representation as a common format; that representation does not mean the conversation is being sent to OpenAI.
A pipeline is an ordered collection of processors, including processors you write yourself. For example, text output can contain structured information that a processor extracts and stores before downstream speech synthesis. Another processor could inject speech content into the stream. This is where the placement of a separate TTS service becomes useful: the application can act on model text before it becomes audible.
Transport events connect application lifecycle to conversation lifecycle. When the client connects, the sample queues the latest context as a frame, Pipecat's object for carrying information through the pipeline. That frame reaches Gemini and initiates the conversation. Disconnect events are available too. Execution has three layers: the pipeline defines the processing path, a task manages that pipeline, and a runner executes the task.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Choose the transport, then detect the user's turn
The transport question has two different answers depending on where the connection terminates.
| Connection | Mark's recommendation | Reason |
|---|---|---|
| Browser or app → agent | WebRTC | Media handling, error correction, audio quality |
| Server → server | WebSockets are suitable | Direct exchange of media streams |
Pipecat supports both, including a FastAPI WebSocket option. Mark strongly recommends WebRTC for client-facing applications: WebSockets can carry the data, but leave a long tail of realtime media problems for the application to solve in production. Phone-provider integrations are a common server-to-server use case for WebSockets.
A separate concern is voice activity detection, or VAD. Gemini and many STT services have their own detectors, but a local detector can let the application react promptly when the user begins speaking. Pipecat emits a user-started-speaking frame and propagates an interruption, clearing the way for the user's turn while the bot is talking.
Mark recommends Silero VAD for local detection. Aleix informally estimates inference at about a millisecond, without specifying hardware or a benchmark configuration. That processing time is separate from the amount of speech the detector must hear before emitting an event, which Pipecat lets developers tune.
Mark also estimates local VAD at a fraction of one percent of agent cost, citing Quinn's cost analysis in which TTS tokens or characters dominate. The spreadsheet and its configuration are not provided, so the practical point is the small local processing burden described for this setup, rather than a general pricing ratio.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Connect phones and distinguish services from orchestration
Phone integration adds connection and call-control choices:
- Provider media streams: Twilio, Telnyx, Plivo, and Exotel can exchange audio with Pipecat over WebSockets. An incoming call triggers the connection handshake.
- PSTN dial-in: The public switched telephone network provides another route into the conversation.
- SIP: A telephony provider can connect to a SIP-enabled Daily room. Mark describes richer call control at the cost of more setup complexity.
The media connection expects an agent ready to receive it. Resources need to be provisioned so callers do not sit waiting for a cold start; Mark's example of a twenty-second wait illustrates the experience to avoid.
An audience comparison with Cartesia clarifies the layers. In the workshop, Cartesia is described as a TTS service with voice cloning and a realtime WebSocket API: send text, receive audio frames. Pipecat integrates that service. Cartesia or ElevenLabs can fill the speech-output slot; Llama or an Anthropic model can supply language generation; Deepgram can supply transcription. Gemini Live combines those model functions, while Pipecat remains the framework assembling the application.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Control behavior without adding unnecessary turns
Aleix interprets a question about responsible behavior as asking how to ensure the model says appropriate things. Pipecat does not make that judgment automatically. The application supplies prompts and can insert processors that inspect responses or perform realtime evaluation before downstream use. Branching is also available: one transport can route audio into one service and video into another, while Gemini Live can handle both within one service.
Checks compete with the response budget. An additional LLM call to inspect every answer introduces another synchronous dependency. Guardrail processors are optional in Pipecat; whether an application needs them is a separate product decision. Mark instead develops a complementary approach: constrain the task and manage the context the model sees.
A restaurant-reservation conversation can proceed through discrete tasks:
- Collect the customer's name.
- Collect the requested time.
- Record the booking in a database.
Feeding the current task to the model keeps the next action explicit. Context can also be retired after it has served its purpose. In Mark's patient-intake example, date-of-birth verification is an initial checkpoint; once complete, its conversation details may no longer belong in subsequent model input.
For longer conversations, an out-of-band request to a text LLM can summarize accumulated context and return a compressed version. This work need not be another serial step before every spoken response. Mark also points to rolling or sliding context windows in Google's Live APIs, tentatively mentioning token caps, and notes that speech-to-speech services can accept text input as well as audio. These mechanisms give the application ways to manage a conversation beyond continually appending its entire history.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Network distance, tool calls, and large context
As connectivity returns, participants retry the repository download and use the AI Engineer Slack for help. The intended channel is workshop-voice-gemini-pipecat; a second similarly named channel briefly creates confusion, and badge instructions provide the route into Slack.
Moving inference closer can remove network round trips. Mark points to European users reaching services hosted only in US regions as an example where distance matters, while qualifying that Quinn has done more direct experimentation with local models. He also mentions Modal as a way to rent GPU time for self-hosted inference. Hosting your own model and running it on a client device are different choices; the discussion does not establish a device-performance comparison.
State management introduces another latency tradeoff. A large context gives the model more material to process, but fetching information through a tool can introduce its own delay. Mark reports sub-500 ms time to first byte for a basic local Gemini weather demo, versus waits of 1.5–2 seconds for the first token with some other providers, including OpenAI. These are informal observations with unspecified model versions, sample sizes, and measurement boundaries.
The mechanism matters more than the provider ranking. In the conversational path Mark describes, playback can begin after the first sentence arrives. In the tool path, the application waits for the complete JSON invocation before acting on it. Streaming some bytes therefore does not necessarily mean useful work can begin.
The World's Fair homepage voice widget makes the tradeoff concrete. Mark first tried exposing speaker JSON through a retrieval tool, but found the response too slow. He then put the speaker data directly into Gemini Live's context.
| Speaker-data approach | Latency implication | Accuracy implication |
|---|---|---|
| Retrieve through a tool | Additional tool-response wait | Select data through retrieval |
| Include all records in context | Avoid that retrieval step | Similar records can be confused |
Mark reports roughly 800 ms response latency under good conditions when the speaker data was placed directly in Gemini Live's context, with variable results. The larger context made all records available immediately, but many similarly structured speaker records could confuse the model—a problem he describes across LLMs.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Prepare credentials and understand the adapter boundary
With the Slack channels consolidated, participants return to the README setup. The workshop supplies a temporary Daily key in .env.example, which Mark says he intends to rotate afterward. Participants obtain their own Gemini key through Google AI Studio. For a new setup, use personal credentials rather than the workshop's shared key.
Pipecat's service classes normalize much of the application-facing interface while adapters translate provider protocols. The bot could use OpenAI Realtime, or a text model with separate STT and TTS, instead of Gemini Live. The abstraction has limits: Mark contrasts the workshop-era handling of OpenAI system-role messages with the named system instructions configured when constructing Anthropic and Google services. Similar interfaces do not make every provider's prompt lifecycle interchangeable.
Noisy environments expose a different boundary. VAD detects speech; it does not inherently know which nearby person should control the conversation. Mark describes using Daily partner Krisp as an input filter in the transport, separately from VAD. It cleans incoming audio before detection, targeting noises such as chip bags and barking dogs as well as background voices. He particularly praises its ability to isolate the primary speaker in conference conditions.
The speech-to-speech options named at this point are Gemini Multimodal Live, OpenAI Realtime, and the then-new AWS Nova Sonic. Mark describes their general conversational latency as similarly good, with different strengths and weaknesses; this is separate from his earlier observations about tool-call delays. Aleix then takes over to build the smallest bot from scratch.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Build the minimal Python agent
Aleix begins with an isolated Python environment named .venv:
bash
python -m venv .venv
source .venv/bin/activate
The environment keeps the bot's packages separate from other Python projects.
Next comes requirements.txt. The Pipecat extras enable the three integrations used here: Daily transport, Google inference, and Silero VAD. python-dotenv loads configuration from .env.
pipecat-ai[daily,google,silero]
python-dotenv
The environment file holds Google and Daily API keys. Aleix copies the workshop configuration, reiterating that its shared credentials are temporary.
In bot.py, an asynchronous main function is launched through asyncio.run(main()) under the standard __name__ == "__main__" guard. The first configured component is DailyTransport: a room URL, a token argument, a participant name, and DailyParams. The demonstration uses a temporary public room without a token. Both incoming and outgoing audio are enabled, and SileroVADAnalyzer lets the transport detect user speech. Aleix corrects a missing display name to AI engineer.
The model configuration comes from the sample's GeminiMultimodalLiveLLMService. Because Gemini Live receives and produces audio, this version needs neither an STT service nor a TTS service. Aleix removes the tools and reduces the system instruction to a helpful assistant. He also omits explicit context storage for this minimal conversation. The processing path is now just transport input, model, transport output.
The execution portion can be expressed as a small function receiving the configured transport and model:
python
from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.runner import PipelineRunner
from pipecat.pipeline.task import PipelineParams, PipelineTask
async def run_bot(transport, llm):
pipeline = Pipeline([
transport.input(),
llm,
transport.output(),
])
task = PipelineTask(
pipeline,
params=PipelineParams(allow_interruptions=True),
)
runner = PipelineRunner()
await runner.run(task)
This preserves the workshop's task configuration, including allow_interruptions=True. A pipeline is itself a processor, so larger applications can compose pipelines inside other pipelines. The example needs one task, though the runner architecture allows more. Finally, os supplies access to environment values and load_dotenv() loads the configuration before those values are read.
The first launch fails with a missing-module error: writing requirements.txt did not install its contents. The missing step is:
bash
python -m pip install -r requirements.txt
python bot.py
While packages install, Aleix opens the configured Daily room with video disabled. The browser participant and the bot must join the same room before they can exchange audio.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Replace the room transport and connect real clients
The Daily room belongs to the selected transport, not to Pipecat's core model. Replacing that transport with a WebSocket connection to Twilio would make the agent reachable by phone instead. Mark also introduces SmallWebRTC, a vendor-independent peer-to-peer transport built on Python's aiortc.
The workshop uses Daily because the team has not prepared TURN infrastructure for the conference network. TURN relays media when direct peer connectivity fails; it is network-dependent, not universally required for peer-to-peer WebRTC. The Small WebRTC transport documentation describes the signaling and STUN/TURN configuration. Mark points to roughly 100 foundational examples covering recording, STT, frame injection, images, and synchronized image-and-audio output, described as using peer-to-peer transport without a Daily key.
Package loading delays the presenter's launch, but an attendee reports a working bot. Aleix estimates the small agent took about five to ten minutes of coding. Asked whether beta labels imply it is unsuitable for commercial use, Mark tentatively estimates hundreds of thousands of Pipecat calls per day while explicitly saying he does not know the actual count. Quinn instead points to large-company production use and contributions from NVIDIA, AWS, OpenAI, and Google.
The Python program is the server-side agent. Client SDKs cover Android, iOS, JavaScript, React, and C++. Connection behavior depends on the chosen transport; Aleix mentions both Daily and LiveKit. For this example, the client and agent become participants in the same Daily room, and WebRTC carries their audio.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Test through voice, then try interrupting
Testing does not have to mean a developer manually talking to every bot. Aleix describes a recently assembled release-evaluation setup:
- Start the agent under test in a Daily room.
- Join an evaluator bot to the same room.
- Have the evaluator ask a simple spoken question, such as what two plus two equals.
- Let the agent answer through its normal audio path.
- Have the evaluator judge the spoken answer.
This exercises the transport and model services together. Aleix says releases previously involved manually running more than 100 examples; bot-to-bot evaluations are intended to exercise services such as Gemini Live, Cartesia, and Deepgram through actual voice exchanges.
The live bot then answers a request for a joke with the familiar scientists-and-atoms punchline. When challenged about repeating it, the bot asks a question back and eventually gives an extended explanation of why people repeat jokes. Its introduction, “From my search,” does not establish that a search tool ran; the minimal build had deliberately omitted tools.
After stopping that explanation, Mark requests a long story so he can demonstrate interruption. As the story begins, he redirects the bot to a new joke. It briefly continues the story, then changes course after a second redirection—and repeats the same atoms joke. The exchange shows working voice interaction and an imperfect handoff, rather than an instantaneous stop on the first attempted interruption.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Silence does not always mean the turn is complete
An audience member raises the opposite problem: agents often start talking when a person merely pauses. A basic VAD timeout waits after speech stops—Mark offers one second, 0.8 seconds, or half a second as possible settings—then gives the bot its turn. A shorter timeout improves responsiveness but increases the chance of speaking over someone. In an interview with a Tavus-style digital twin, a person may need time to think before continuing.
Semantic end-of-turn detection adds evidence beyond silence duration. Filler words, pauses, intonation, and conversational context can indicate whether the speaker has finished. Mark introduces Smart Turn as a native-audio classifier that returns complete or incomplete. In the integration he describes, an incomplete result can extend the VAD timeout, giving the speaker three seconds to finish the thought before a response.
This is a dynamic decision about how long to wait, rather than one fixed silence threshold for every utterance. Mark describes natural turn-taking as unresolved at the time of the workshop, with model providers and STT vendors exploring similar approaches, and expects substantial progress over the following year.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Synchronize visible words and assess offline speech
To show text while the bot speaks, the application needs more than the completed response string. Mark notes audio-and-text output from speech-to-speech services, then explains the more specific TTS alignment path. Providers such as Cartesia, ElevenLabs, and Rime supply word-and-timestamp pairs. Pipecat TTS services emit audio and text frames, and an observer watches those frames pass through the transport to emit client events. The client can then display words in sync with playback. Mark recalls the callback name tentatively, so the useful contract here is the synchronized bot-TTS-text event rather than a particular spelling.
A fully offline agent is possible in principle, but its task determines the model and hardware requirements. A narrow restaurant-reservation bot might work with a local Llama model; more demanding reasoning may require larger on-premises or cloud resources. Mark mentions challenges with Whisper for STT and emerging local TTS options, without prescribing a complete offline stack.
Speech understanding is an upstream dependency for everything else. Misrecognition can make even a capable model answer the wrong question, and native speech-to-speech models can misunderstand input too. Mark tentatively identifies STT as the hardest offline component to get right. Quinn has been experimenting with local models, but Mark clarifies that Daily is not developing an STT model. Aleix observes that local inference could also have avoided the workshop's network dependency.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Word Wrangler: control what each agent can hear
The closing example is Word Wrangler, a Catch Phrase-style game: the human describes a word without saying any part of it, and an AI player guesses. Mark directs participants to Pipecat's community and sample projects, including both a browser version and a phone version of the game.
The phone version puts two Gemini agents in one call using parallel pipelines. One is the host, which gives the human the prompts. The other is the guesser. Selective audio routing keeps the guesser from hearing the host: it receives the human's clues instead. This makes routing part of the game rules, because the guesser must infer the answer from the player's description rather than hear it announced. Mark identifies Twilio for the phone version and a React/Next.js-style client for the web version.
The live web game opens by explaining the rule against saying the target word. Mark describes something on a phone used to take pictures; the agent guesses camera. A field concerned with language becomes linguistics, a racket sport with a yellow ball becomes tennis, and a round dessert with chocolate chips becomes cookie. The displayed final score is 4. The workshop ends with Gemini Live participating in a concrete game whose behavior depends on both native audio understanding and the application's control over who hears what.
Suggest correction
This note stays in this page until you copy or download it. Nothing is submitted; reloading clears the draft.
Resources
From the talk
Workshop setup instructions with browser and Twilio chatbot starters. Use your own credentials; the shared Daily key was workshop-only.
Open-source framework for orchestrating voice and multimodal agents.
Local voice activity detection models with Python examples and PyTorch and ONNX support.
Audio-based turn detection with model weights and local inference examples. The repository now documents v3.2.
Archived web and phone guessing game illustrating parallel agents and selective audio routing.
Further reading
Daily's 2024 account of optimizing voice response latency through model selection, WebRTC, and colocated inference.
Updates since the talk
Current Live API guidance, including audio transcription configuration and response modalities.
Current signaling, client connection, and STUN/TURN setup for Pipecat's peer-to-peer transport.
Read the complete timestamped transcript
- 0:00
[on-hold music] I'm Mark with Daily.
- 0:16
This is Aleix.
- 0:17
Aleix.
- 0:18
And then we have a few other Daily folks, uh, Quinn, Nina, Varun, and then I'm not sure where he went, but Philip from... Right there. From the Google team, Google DeepMind team.
- 0:30
So this session, we're going to spend just a few minutes getting everyone started. The idea here is it's going to be a hands-on workshop where all the folks I just called out are gonna be available to help out.
- 0:40
We'll walk you through a quick start to get you up and running, and then the idea is to build something. So build a voice bot in the next 78 minutes and 12 seconds or whatever time we have left.
- 0:51
Um, the one... I guess there's one, uh, consideration is the Wi-Fi. If you don't have good Wi-Fi, you might wanna try to tether. I was able to tether, and it worked fairly well, but the conference Wi-Fi was a little shaky.
- 1:03
This is real-time, so you will be streaming data. It does require a viable connection and not just sending, you know, a few bits over. So just a heads-up if you hit that as a, as a snag.
- 1:15
So I guess before I get started, who here knows about Pipecat or has built anything with voice AI? Okay.
- 1:25
A smaller audience. Has anyone built any real-time applications with LLMs or AI?
- 1:32
Maybe slightly bigger. Okay. Great. So Pipecat, um, is a, uh... It's an open source repo. It's a Python framework for building voice and AI multimodal agents. And it's built by the team at Daily, um, but we're an open source.
- 1:49
It's an open source project that, uh, anyone can contribute to. It's been around for, I don't know, just over a year now, and-
- 1:57
Yeah. Like, I would say officially Pipecat was March 2024.
- 2:02
Okay.
- 2:03
Something like that.
- 2:03
So 13 months.
- 2:04
So over a year, yeah.
- 2:05
There we go. So just a quick, uh, walkthrough, maybe just to kind of ground everyone in the thinking around voice AI. Uh, these slides weren't built for this talk, but I'm gonna use them.
- 2:15
So the, you know, voice AI or v- real-time applications are tough because there's just... You know, we as humans communicate all the time with each other, thousands, ten thou- tens of thousands of years of evolution baked into our brains.
- 2:26
So it, it's pretty tough to make a machine, you know, work on, on the same level. So we have great expectations being the user in it. So, you know, you need a good listener, somebody that's smart and conversational.
- 2:37
You need to be connected to data stores. Uh, it has to sound normal or natural. Think back to even just maybe two, three years ago what your, you know, voice bots sound like.
- 2:46
And many of them on, if you call them on the phone, still sound like... It needs to sound natural. And actually, kudos to the Google team. The latest, uh, Gemini Live, uh, native audio dialogue is quite good in that regard.
- 3:00
It has to be fast. So the whole end-to-end communication needs to happen in roughly, you know, kind of the, the benchmark is around 800 milliseconds. Um,
- 3:09
y- you could strive for more. I think we see, uh, maybe on the human level, it might be 500 milliseconds or somewhere on that, uh, order. So it is pretty fast.
- 3:17
So there's a lot to kind of, to get all the way there. And this is something that we at Daily, everyone building Pipecat has been working very, very hard on, uh, getting all the way to meeting all these expectations.
- 3:29
So just to kind of ground you in some of this since we're going to be working in Pipecat, Pipecat has a pipeline. I don't know if maybe, Aleix, you wanna talk a little bit about the origin of that quickly.
- 3:38
Sure. Sure. Uh, you can think about it as a multimedia pipeline. And you would think, "What is a multimedia pipeline?" It's basically just think about, like, boxes that receive input, and input could be audio or video.
- 3:51
And then those boxes just will stream those, uh, same data or modified data or new data to the following, uh, to the following elements or processors. In, in Pipecat, well, we call them processors.
- 4:05
So in, in Pipecat, you would have a pipeline where you have a transport, which is the,
- 4:13
the inc- the transport of your data or the input of your data. For example, when you're talking, [clears throat]
- 4:19
you could be talking in a, in a meeting, so that would be the audio of the user. Then you would have, uh, another box following that, which is the speech-to-text service.
- 4:28
So y- the speech-to-text service would, would grab, uh, audio from the user. It would tran- uh, transcribe it. Then you would get text. That would be the following, uh, data that goes through the pipeline.
- 4:40
And then the next one would be the LLM. So now the LLM has what the user has said. [clears throat]
- 4:46
And then it generates, uh, output, whatever, uh, whatever the LLM. That would be tokens. Then those tokens are co- are, are converted into, um, text-to-speech. And then the text-to-speech outputs audio, and then the audio goes back to the transport, so you could hear what the LLM has said.
- 5:05
Today, uh, what we're gonna do today with Gemini Live, a lot of those boxes go away because, uh, um, the LLM will do a bunch of the things. It will do transcription.
- 5:16
It will do the LLM. It will do the text-to-speech in, in one of these boxes. But you might still require, for example, if you wanna save the audio or record the audio into a file, you need a bunch of utilities to do that, and Pipecat has all that built for you.
- 5:31
Um, so basically-
- 5:33
Yeah
- 5:33
... that's, that's it.
- 5:34
I mean, well, a lot, a lot of this is really just or- it's orchestration. So if you think about what Pipecat offers, it's orchestration. It also offers a lot of abstractions for a lot of common utilities like Aleix had said.
- 5:44
So recording, uh, transcript outputs, artifacts you might wanna produce, or even ways that you might manipulate the information in the pipeline itself. So this, uh, image here, which is what Aleix actually just talked through, is what you would call, I guess, a cascaded model, where you have This flow through of information.
- 6:02
So we're going to be-- You can build with Google and many different services in this way. Uh, in the last year, there's been an emergence of speech-to-speech models that now take audio in natively and audio out natively, and those models also allow for audio in and then optionally text and/or audio out.
- 6:19
So you can actually, for example, take a raw, you know, microphone input or, uh, you know, audio input, and then
- 6:28
the model would run all of its logic, and you can actually opt to have it output text if you wanna, say, parse the text output before speaking. So there are a few different demos we'll look at that offer that.
- 6:39
Uh, and in Pipecat, we show kind of all the ways to do things 'cause that's, that's what we offer, or at least what Pipecat offers as a, as a value proposition.
- 6:47
So the, um-
- 6:48
Yeah, just one thing. I don't think-
- 6:49
Yeah
- 6:50
... you mentioned it in the slides, but all these boxes you can plug and play the service you want in Pipecat. So the speech-to-spe-- uh, speech-to-text, it could be, I don't know, Deepgram, for example.
- 7:01
The LLM could be, uh, Google or OpenAI or whatever. You ju- can just plug and play any service you want.
- 7:08
Right. Yeah. The modularity, I guess, is the other big strength. So there's no... You know, you can change out a service without changing out your underlying application code, which makes it easy.
- 7:16
And we see with this a lot of companies that are building for voice AI might have, uh, maybe even a more complex thing. A pipeline here runs straight down, but you can actually have split branches where you might have one leg that's running some logic and the other running different.
- 7:30
We call that a parallel pipeline. So if you wanted to have, say, a failover, if vendor A goes down, you can move to vendor B dynamically, w- even within the same conversation.
- 7:41
That's something that Pipecat affords as well. Um, and that can allow you to transfer contexts over. So a lot of really cool stuff. Uh, the goal again today being to get you familiar with just building a voice agent and building one to get started.
- 7:56
So one of the cool things, um, like Aleix had pointed out, that with the cascaded models, there's a lot of complexity, but with your speech-to-speech model, things get, you know, dramatically simplified.
- 8:08
You know, your code may have looked something like this. This is, like, an old example of some, like, a ton of, uh, orchestration in the pipeline. But with a speech-to-speech model, you may be able to simplify it down to this, but then you have to remember you actually need orchestration around it.
- 8:24
So it does get simpler to some regard. Um, so it's, it's more about the services you interface with. Uh, I think with that, why don't we transition now, 'cause I'm realizing we have only about maybe 70, 70, 75 minutes left, to looking at, um, the actual activity for today.
- 8:42
All right. So there's a public repo. I don't know how big or small this is, but it's under Daily Co. So on GitHub, Daily Co, daily-[REDACTED:url]-workshop. I'll give everyone a chance to make sure your internet's working and-
- 8:59
Can everyone see the, the repo URL?
- 9:00
Yeah, it's really tiny. Yeah. Okay. I should have it in big text somewhere. Oh, no. Not really.
- 9:10
No. Here we go. All right.
- 9:30
Let's take a look at this. So what, what I want to do... So there are-- I spent a little bit of time, Aleix and I spent time writing up this repo.
- 9:37
This is meant to be just a jumping-off point. I'm gonna get you oriented, and then I want to look through one of the bot files, which is kind of the main Pipecat code with you.
- 9:46
And then we'll break and make this, uh, an interactive session where we can answer a bunch of questions. So in the repo, um, you could either start doing it now or maybe take a pause, but this will give you the steps to walk through getting the quick start running.
- 10:01
Before we do that, I wanna take a moment here. Let's see how the Wi-Fi's doing. That's not a good sign.
- 10:11
Uh, Wi-Fi is down. It's down? Ah. I take comfort in no Wi-Fi. Well, hey, you know, it is tough to do Wi-Fi for this many people.
- 10:19
Yeah.
- 10:19
Very, very tough.
- 10:19
Instead of real-time, it's gonna be real slow.
- 10:22
Real slow. Yeah. [chuckles] Real slow voice communication. All right. Well, we're using WebRTC.
- 10:27
Yeah. [chuckles]
- 10:28
Yes. Yeah. There will be some... Okay.
- 10:31
Yeah.
- 10:31
So in, uh... Here is this gemini, uh, bot.py files. This is all Python again, so we... Everything will be in Python. There will be some client code options which, which we'll look at in a second.
- 10:43
Um, just to orient you, I'll just jump right into the meat of the pipeline. We have this main, uh, function that runs your bot. Everything's going to run kind of encapsulated within an AIOHTTP session.
- 10:57
We're gonna pass that session around. That's more of just kind of the mechanics of things. In our pipeline, let's just jump to the, the simple part here. We'll have Daily as the transport.
- 11:06
Daily is-- We are a WebRTC provider as well as we build Pipecat. Uh, there will be context aggregation. So one important note, when you speak, uh, every turn of the bot is a, like a, a discrete point in time.
- 11:22
And this is maybe less so the case for a speech-to-speech model, but for basic LLMs, they get discrete inputs. Everything is like a REST API call, so you're going to get a snapshot of the conversation.
- 11:33
The context aggregator is going to collect the, all the bits of the conversation, both from the user and the assistant, uh, and will put that into the form of what the LLMs can handle.
- 11:44
So this, in this case, is more for function calling and kind of logistics and management. Gemini is amazing because it offers a lot of this for you. But if you're to build with, say, the, uh, just build with Gemini not live, the actual kind of just the text-based LLM, you'd have to have this context aggregation Uh, that
- 12:05
will then go to your LLM, which is going to be Gemini Live, Gemini Multimodal Live, and then it's going to be outputted through, uh, Daily again on, on that side of the transport.
- 12:16
So you have Daily. We'd configure our service, which takes a number of arguments. Like, you set up a room with a token, give it a name, and then have some properties.
- 12:25
There are docs which I'll link to, uh,
- 12:29
in the-- It's linked in the quick start. There's also a Gemini Multimodal Live LLM service, which is a Pipecat class that is a wrapper around the Gemini Live API.
- 12:39
So this, again, you just initialize and run. With the LLM, you see we do a few special things. We're going to define tools. This one has just two really basic kind of canned functions.
- 12:51
Fortunately, we're not calling out to the internet 'cause it's not working very well. Um, our connection's not working well. So this one just has the dummy, like fetch weather, and we'll give you a restaurant recommendation.
- 13:01
So these are two handlers that when your function is called, we'll just return this result information. Uh, so we have the actual functions themselves that are defined in this function schema, which is you can use just native function, uh, definitions using whatever LLM format.
- 13:20
We also have created this function schema, which is a universal schema that lets you define, uh, and move between any LLM without having to kind of transform your LLM calls from OpenAI to Anthropic to Gemini to Bedrock, 'cause they're all a little bit different, or Groq.
- 13:36
You know, they all have slightly different formats. So this is more of kind of a universal transform for that.
- 13:42
And then they're collected and trans-translated into the native format in this tool schema. So we'll pass the tools then to the Gemini service, and that's how it gets access to use and run those tools.
- 13:55
There's also a prompt above which I think in this simple example, we just say, "Hey, you're a chatbot. You have these tools available." Uh, and that's that.
- 14:04
We're also setting up our context aggregation, which
- 14:08
for better or worse, we use a-- OpenAI as kind of the default, like, uh, the lingua franca for context, so everything gets kind of folded back into OpenAI, uh, at a certain level.
- 14:18
Um, and then we define the pipeline. So the pipeline is, again, like Aleix had said, just a list of all of your different, uh, or is I guess a tuple of all of your different services, um, that are running in the pipeline.
- 14:31
And you can write your own. So if you want to instead make the LLM output text and you want to either extract information from them, maybe you in-- have it in code, some XML or some type of information, you can actually extract it, store it.
- 14:44
Maybe your application does something with it. Um, or maybe you want to inject a text-to-speech type of, uh, frame. You can actually do that by separating the LLM, the, that audio output from audio output to, uh, just be text, and then we-- you would add like a text-to-speech service here.
- 15:02
Or you could write your own processor, which may be not within the next hour. And then lastly, all of these are, not all, but many of them have, uh, events they emit.
- 15:11
The transport emits handlers for when the client connects and disconnects. So in this case, uh, we use this line here to actually inject a context frame into Gemini to k-kick off the conversation.
- 15:25
So when your client application connects, it's going to queue a frame. So again, frames being kind of the base format for, uh, information. Think of it as like an object for your pipeline.
- 15:36
You're going to queue one of those frames, and what this function does is it just grabs the latest context. So when we set this one above, I think that just says hello, that's going to pass that into, uh, or basically push that into the pipeline, which then it will make its way to, uh, to Gemini to initialize
- 15:53
the conversation. And the rest of this you could think of as boilerplate to run it. You create a runner, which then is the thing that actually runs your task, and the task is what runs the pipeline.
- 16:03
So maybe beyond today, but just know that that's something that's required to run your code. Okay, I'm gonna pause here just for any questions, 'cause I do wanna get to developing soon.
- 16:14
Um, so you said it was a WebRTC. So you can provide a WebRTC server. You provide WebSockets as well?
- 16:20
Mm-hmm. We provide both. That's a whole topic that is a talk in itself. Um, the short answer is if you're building a client-server app, you should, with like strong emphasis, use WebRTC.
- 16:32
It has a whole bunch of properties that are relevant, like error correction, better audio quality, et cetera, et cetera. If you're building server to server, so one of the options today is to build a phone chatbot.
- 16:43
You can use, and it's probably the best option to use WebSockets. So you can bring your own, uh, transport. We actually, in Pipecat, there's a, a FastAPI version of that that's a server that you can use to exchange messages with a WebSocket.
- 16:57
So yeah, it's really up to you. So I guess maybe the, the takeaway is if you're building client server, you really want WebRTC. You could technically use WebSockets, but you'll hit like a long tail of err- of errors when you get to production, and then server to server, totally fine.
- 17:10
You're gonna be fine with WebSockets.
- 17:15
Could anyone download the repo by any chance?
- 17:19
Did anyone not-
- 17:20
Just one person
- 17:20
... download the repo?
- 17:21
Two persons. Three, four.
- 17:23
Wi-Fi's dead. Man.
- 17:24
Wi-Fi's dead.
- 17:25
Is it-- Can anyone-- Can you tether? Is that an option? Do folks have tether hotspots on your phone or... That's even shaky? Oh, geez. Okay.
- 17:32
You have a hotspot. Yeah.
- 17:34
I can dance. Could do some... I don't know. [laughing] You know, I, I'm not really, you know, it's not my thing, but I could try.
- 17:41
True. Yeah. We-- I guess I could just make this a code walkthrough. Um-
- 17:46
Or we could write it from-
- 17:48
What about VADs?
- 17:50
What-
- 17:50
If you use some other VADs-
- 17:51
Yeah.
- 17:51
... Gemini have its own VAD or...?
- 17:52
Gemini does have its own VAD. Yeah.
- 17:54
What's your favorite choice in voice activity detection?
- 17:57
Gemini does have its own VAD. In fact, if you're using a speech-to-text service, that likely also brings its own VAD to the, to the equation. What we've found is that, so Maybe to use some of our extra time because we're having internet issues.
- 18:10
Um, the VAD serves a really important purpose of detecting when a user starts speaking. So in the whole kind of life cycle of a turn, that user speaking kind of ushers in the user's turn for the conversation.
- 18:22
So Pipecat will emit a user started speaking frame, and that will also push through an interruption. So the user will interrupt like anything that's talking. So if the bot was speaking or whatever, uh, it basically clears the way because the user has expressed that they want to speak.
- 18:37
The idea with the VAD is that we want it to be extremely accurate and extremely fast. So running something on device, we recommend Solero, which is an open source option.
- 18:46
It works incredibly well. I don't know what the inference time is like. I don't know.
- 18:51
Millisecond.
- 18:52
Millisecond. Extremely fast. So you're going to get an event back, uh, fast. In fact, you have the ability to tune how long to hear human speech before that event gets emitted.
- 19:02
And there-- the defaults are pretty good in Pipecat, and there are maybe scenarios where you wanna change that. But the VAD is a really important, uh, consideration. It's extremely low CPU consumption.
- 19:12
Quinn has a great, uh, spreadsheet of breaking down the full cost analysis of an, an agent, and really the CPU is going to be extremely low. Interestingly, the TTS tokens or characters are, are the most expensive by far.
- 19:25
Um, so when you think about it, running that local VAD gives you superior performance, and it allows you-- And it-- There's not much of a cost hit. I mean, it's maybe like a fraction of one percent to run a local VAD.
- 19:36
Um, but yeah, you have all sorts of choices. But we find, we find that to work really well. Mm-hmm.
- 19:43
Is Pipecat integrated with phone carrier and like that or just web?
- 19:48
Uh, it's integrated with phone carriers too. So there are a ton-- There are-- I found out-- I didn't work much with phone. Varun's been our phone expert, though I don't-- Varun is like a figure in the WebRTC community.
- 20:00
He's like an author of many things. But he's also a phone expert, which I don't know if that crosses over too much. [chuckles] It was-- Maybe that happened before. Um,
- 20:11
phones are super complicated, how you actually make calls. Um, Pipecat supports all of them. So maybe a very quick list. You can make a WebSocket connection with a phone provider like a Twilio or Telnyx or Plivo or Ex-Exotel and exchange, uh, media streams.
- 20:27
So that's a way to have just a, a native WebSocket connection from Pipecat to Twilio. You'd call Twilio, it's going to emit the WebSocket, and there'll be a handshake to get connected.
- 20:38
You can also use, uh, PSTN, which is a public switched telephone network, uh, which is lets you dial in, and that's gonna be kind of a different mechanism. There's also SIP, which is its own separate thing again, and all of the telephony providers would also support this as well.
- 20:55
With SIP, you would call, um, something say like Twilio, and you would call into like say a server like, uh, or a SIP provider like Daily, which is offers SIP provided rooms.
- 21:07
And you then have the ability to kind of, uh, bring the two together via that SIP connection. The nice thing about SIP is that you have the ability to have like superior call control.
- 21:16
It does-- It is slightly more complicated, whereas that WebSocket connection is instantaneous. Your bot needs to be up and running. So there's a whole... We're not gonna talk about it today, but like cold starts for agents, they need to start immediately.
- 21:28
So if you don't have resources provisioned, you don't want your users waiting like twenty seconds while the bot comes online. So a long-ish, medium-ish answer for a very complicated question, if you didn't know that.
- 21:42
Okay. You can-
- 21:42
Yeah, yeah, yeah.
- 21:44
Could you compare with something like Cartesia, Pipecat plus, uh, Pipecat, Pipecat giving birth to something like Cartesia?
- 21:55
Can take that. Yeah.
- 21:56
Yeah. I'll, I'll let you answer that.
- 21:57
Yeah, yeah. Cart-Cartesia of-
- 22:00
What's the question?
- 22:01
Yeah. Can you-- I didn't hear it. Can you repeat?
- 22:03
Well, I think you were, you were asking if Pipecat compares to or how it compares to, uh, Cartesia. Is that-
- 22:11
Yeah, yeah. We heard first.
- 22:11
Yeah. Cartesia is, uh... Well, I think they're gonna do more stuff, but, uh, as of today, it, it's a text-to-speech service. And you can clone your voice or you can, you know...
- 22:22
And then they provide a real-time, uh, API. You can just via WebSockets, you pass the text, and they reply with, with audio, basically, with audio frames. And then Pipecat integrates with Cartesia as any other text-to-speech service like ElevenLabs or, or anything.
- 22:39
Like think about Pipecat as a j- it's just a framework for developers where they can plug and play the service they want. So they can plug and-- They can take Cartesia, they can put Cartesia, they can take it out, put ElevenLabs.
- 22:52
Oops. Whoop. Even closer. Okay. Now I can hear myself. Um, yeah, you can plug and play any service you want. Like you can change LLM, you can use Llama, you can use Anthropic, you can use, uh, Cartesia or ElevenLabs.
- 23:09
Then for, uh, speech-to-text, you can use Deepgram, or you can use one box like Gemini Live, which has all that, uh, built for you. So
- 23:20
is that, that clear? Yeah. Yeah. Okay. Yeah.
- 23:24
Um, what about what behaviors? Okay. Uh-
- 23:27
About what, sir?
- 23:28
What behaviors. What behaviors. So, uh, uh, uh, I, uh, I mean, so we are talking about, uh, uh, voice product, right? The right to production. For instance, if you are trying to use, right?
- 23:43
The voice value. So what about the responsibility AI? How, how, how are you, uh, like focusing on create-- Uh, sorry about my English. These, what behaviors, right? Is that, uh, for guarantee that the models were responsible, something that is for right for the, for the professional and the author and the user, uh-
- 24:12
Mm-hmm.
- 24:13
I don't know if I can... If I get myself muted.
- 24:16
You-- Um, uh, I, m- I'm not sure [chuckles] if I understood. Are you talking like how to ensure that the LLM says what the right thing or not the right thing?
- 24:30
Yeah. Well, Pipecat doesn't have control about that. It's up to you to define the prompt or define how the LLM will, um, uh, will reply. You can put-- If you want, you can put, uh...
- 24:44
You'll be able to write your own processors that we call them, those little boxes, and check what the LLM has said, for example, before it's, um... Like put some kind of real-time eval, like to, to make sure, uh, that the LLM has re-- You could, you could do that, yeah.
- 25:02
You-- The, the-- All that, that pipeline is very flexible, so you can, you can, you can put whatever you want there, like in parallel, not in parallel. For example, Mark was saying about parallel pipelines, like if you have video and audio at the same time.
- 25:19
Uh, with Gemini Live, you can do everything in one box. But let's say you don't have Gemini Live, you wanna use other, uh, other services that one does video and the, the other one does audio.
- 25:29
You can have a parallel pipeline which, you know, it's like a, a tree, right? You, you s- have your transfer input, and then if it's audio, it goes this way; if it's video, it goes that, that way, and you can, um, you can do things dynamically like, like that, yeah.
- 25:44
Yes, next question. Yep.
- 25:46
Yeah, I have a related question. Um, is that common that people put some kind of check, uh, in place and you see like what is the extra latency of sort, uh, that that produces?
- 25:57
And then for models like Gemini Live that produce audio and video, it seems like... Do they also produce the text with it, or do you have to kind of do speech-to-text again and then back to-
- 26:10
S-sure
- 26:10
... speech and you're losing all that extra [audio static]
- 26:14
Okay. So the question was, um, are guar- are guardrails requirements, and do-- how do people use them? And how does that apply for speech-to-speech models? So the answer is they're not required.
- 26:27
In fa-- Uh, there is a challenge here, and actually be-- Uh, I talked about this on like one of the first slides. Latency is absolutely critical, so what you want to avoid are unnecessary turns.
- 26:37
You know, obviously, LLMs are amazing language processors, so if you had all the time in the world, you could do hallucination checking against the LLM. There are other strategies to handle this.
- 26:48
One of the big things is that we see because of the aggregate nature of the context, it grows over the course of the conversation. You actually... You can find better, um, better accuracy with the responses if you have more control over how you prompt the LLM.
- 27:04
So this is, uh, a whole topic and talk in itself. Uh, what we found is there are two ways to handle this. Well, at least two. Um, one, if you...
- 27:14
For a lot of conversations, they're going to be task-oriented. So let's say, uh, something simple like a restaurant reservation bot. It may have to take your name, get your time, log the time to a database.
- 27:24
You can chunk that out, even that small conversation, into just discrete tasks, and LLMs are really good at, uh, following the most recent input. So if you kind of feed it task by task, that helps.
- 27:37
Also, if you control the context window, like the size, it can really be beneficial to kind of manage that really judiciously. So you could either reset. Um, one example might be, let's say you're building a patient intake bot at a doctor's office.
- 27:50
They may... The very first thing it may do is verify the date of birth, which serves no utility beyond just the very first, you know, checkpoint. So you may actually remove that from the context, like completely get it out of there, 'cause otherwise it's just cruft that hangs on, and instead you kind of reset and then maybe
- 28:07
roll through the tasks. You could also, for really, really long conversations, summarize the c- the context. So you, you may wanna do an out-of-band LLM call. And this is something actually Quinn just ta-- We talked internally about this, that we're going to see more and more of this mixture of LLMs where even in the context of real-time,
- 28:23
you may have an out-of-band like REST call to the, to the text-based LLM just to do a summary and then return it back so that you can kind of compress that context window.
- 28:33
And just to give a call-out to Google, the, the live APIs, so maybe transitioning there, they offer context, uh, management through a bunch of different str- different strategies, like a rolling...
- 28:42
They have a rolling window or sliding window. I think they offer like token caps for that, so you can have some control. Or if you want, you can output text and then kind of do whatever you want with it.
- 28:52
They also take text input, so there's a lot of, a lot of flexibility with speech-to-speech models. They do offer or they do pose some other maybe development challenges, but offer like tremendous benefits in terms of the features they offer.
- 29:05
All right. I'm gonna-
- 29:05
I think there's a question-
- 29:06
I'm gonna hold questions just for a sec 'cause I, I've heard the Wi-Fi is back. Can folks try downloading the repo again? 'Cause I-
- 29:14
Slack channel.
- 29:15
Slack channel. Yes. Quinn, can you maybe come to the mic and... I can't remember what you told me.
- 29:21
Uh, uh, workshop-voice-gemini-pipecat with dashes in between on AI Engineer Slack.
- 29:28
Okay.
- 29:28
So-
- 29:28
Does everyone know where that is? I know this is like day one, hour three.
- 29:32
Workshop-voice-gemini-pipecat is the channel name.
- 29:36
So if you go to the AI Engineer Slack and search for workshop Gemini, it should come up. And Quinn and Aleix will be posting links as we go along if the Wi-Fi stays up.
- 29:47
Um, if anyone can get on that channel, can you raise your hand so we-
- 29:51
Can people jo-- Like do they have a-- Do you guys have access to the Slack, AI Engineer Slack?
- 29:57
Get Slack. There's two channels. There's two channels. Well, workshop-gemini-pipecat and workshop-
- 30:05
Oh, yeah. There's like... Yeah.
- 30:09
So we'll explain what that happened when the Wi-Fi was down and we were trying to
- 30:14
Yeah. I'll take a question over here
- 30:15
On your bot, there should be the Join a Slack group
- 30:18
All right. I'd say, uh, I'm gonna t- I'll take that one, then I'll walk forward. If I could, let's just try maybe listen and also try to get the repo.
- 30:25
I'd like to walk through the quick start, and then we can look at some examples.
- 30:29
You mentioned moving the VAD to local processing. Do you find that there's, like, any advantage in moving more of the pipeline locally, or is that kind of offset by the lack of processing power on client-side devices?
- 30:41
I... You know, it's something actually, uh, Quinn has done a ton of work with this. I have not personally. I mean, there's obviously massive latency benefits because you cut out network round trips all over the place, so you save a ton.
- 30:51
And depending on where you are in the world, that can save a lot. If you're US-based, you know, your network latency is gonna be relatively low. But a lot of the developers in the community are in Europe, and a lot of these AI services are relatively new with, you know, uh, data centers only in the US.
- 31:05
So there are different challenges when doing that, though, when running it. You... It... Actually, there are great, um, hosting providers like Modal that offer really good options for running, like, your own local LLM, which then you're not...
- 31:17
You know, you're buying or I guess leasing, like, the GPU time instead of running everything on a GPU, which would probably be cost-prohibitive 'cause because of the way processes run.
- 31:25
But that's, uh, that is also a talk in itself. Um, next question.
- 31:32
Just one on kind of state management with Pipecat.
- 31:34
Sure.
- 31:36
Um, have, have you seen specific use cases where like making tools more stateless or instead of just pushing everything into this, um, large context window-
- 31:46
Oh, yeah. Definitely
- 31:47
... makes a significant difference? But that can also, from your experience, that that causes more latency for the local device.
- 31:56
Well, the large context windows definitely cause LLMs to process slower. Um-
- 32:02
Can you repeat the question?
- 32:02
Yeah, I'm sorry. The question was around state management with, um, with LLMs and whether it's better to, I guess, chunk or have more kind of deterministic input versus just a large context where you just dump everything in.
- 32:14
This is actually an extension of what the other gentleman was asking. Um, the idea being that, uh... And actually, w- so Daily, we built the chat widget that's on the homepage of the Voice AI World's Fair, uh, page.
- 32:30
I, I, I personally built that. What was interesting there is that, um, and Aleix and I were just talking about this, function calls in the context of real-time are still slow, unfortunately.
- 32:40
Like, too slow. Um, actually, Gemini, [chuckles] I'll give more props to Gemini being, like, maybe one of the fastest. If you run, like, a basic local, like, one of these demos and you ask it what the weather is, it will return back with time to first byte in, I don't know, less than 500 milliseconds.
- 32:56
Whereas other vendors, not trying to throw OpenAI under the bus, but it has, has gotten slower. Like, the... You might see upwards of 1.5 to two seconds of waiting just to get that first token back.
- 33:07
And we dug into it. Actually, this is just something recently this morning. The issue is when you get the normal streamed response for the conversation, you can start playing that audio out once you get the first sentence.
- 33:15
The issue being when you get a tool, you need the entire JSON response before you can actually do anything with it. So that's slow. Uh, that's one part of it.
- 33:24
Se- separately, chunking the prompts is absolutely the way to go. Uh, in building that World's Fair bot, um, I was kind of balancing between the two worlds because, uh, you can talk to it and ask it about speakers for the session.
- 33:37
Route one would've said, "Let's use, like, a mag approach and put all of the, the speaker JSON in something that could be a tool that could be accessed." And I tried that, and unfortunately, it's just a little too slow.
- 33:49
It's a giant context. It takes a while to come back. What's interesting is if you instead move that all just directly into the context with Gemini Live, it's a little bit variable, but under good conditions, you'll get a response back on that, like, 800-millisecond latency.
- 34:03
So it actually has access to, like, the full context. The one trade-off, though, is what this gentleman over here was asking is accuracy. It's gonna get confused 'cause especially when you get a JSON with a lot of speaker...
- 34:14
And this isn't-- This is all LLMs. It's not specifically Gemini. With that type of even structured data, it becomes very hard to kind of discern what's what when a lot of it looks the same.
- 34:23
So it's all... I mean, a lot of this is emerging like other things in, in AI. We're trying to just do it as fast as possible with voice. Before I take one more question, I wanna check in on have folks have, uh, any luck with the repo?
- 34:36
Got a thumbs up. All right. I'm gonna pause on questions for the time being. We can take them at the tail end. I do wanna try to go through the quick start if we could.
- 34:45
That would be great. And, and again, to know, um, we consolidate channels. There's one channel in the Slack. It's workshop-voice-gemini-pipecat. Quinn is in there answering questions. Roen will join, and we're gonna share links there.
- 35:00
So Mark, that's great.
- 35:01
Okay, great. So I would recommend, um, maybe we'll just take, like, a few minutes of independent getting set up if you all go to the README on in the Gemini Pipecat workshop.
- 35:14
And if you'd roll through the first few steps, maybe get a, I don't know, a hand up. You could just flash it up real quick so I could see when people start to get through it.
- 35:23
Um, you don't have to hold it up. If you don't mind, if you brought a device. Okay, we've got one,
- 35:29
two.
- 35:32
So do we need a key?
- 35:33
Ah. So for this workshop, I have leaked my key, a key from one of my accounts, which I'll cycle after this, so you don't need to sign up for a Daily account.
- 35:42
You do need to sign up for a Gemini account. So I don't have a key I can just give out. So in the environment.example, you'll see there's already a Daily key which you can use.
- 35:54
Do people know how to sign up for a Gemini-
- 35:56
I have it in the README
- 35:57
... account? Do you have a direct link?
- 35:57
Uh, it's through AI Studio. Is that a good spot to do it? Okay. So...
- 36:10
You can do it. Can you do that? You can do that. Get your computer.
- 36:14
There we go.
- 36:16
All right, I'll take a question while we're waiting
- 36:24
In the Pipe- in Pipecat, or are you still needing to do-
- 36:26
We-
- 36:27
... most of it yourself?
- 36:28
So in terms of, um, the pipe... That's a good question. In terms of the Pipecat interface, you interface with the Pipecat class, so there's a service class. In- within Pipecat, so how you write your application code, is going to be uniform across all of the services.
- 36:43
The individual, um, providers haven't really... Unlike the text-based LLMs, they haven't really settled on kind of a, a standard. So Pipecat handles all that translation on your behalf. And I think there are other frameworks that do similar things.
- 36:56
The idea is to provide, like, a uniform, simple interface, uh, s- so that you could take... And this is part of the modularity. If you wanted to, you could swap this bot out for OpenAI real-time or, you know, a text-based model with a TTS, an STT paired with it.
- 37:12
That's kind of the whole, whole idea. There is maybe a little bit in terms of, uh... The one thing LLM providers maybe that... I don't know if anybody here can [chuckles] nudge anyone you know.
- 37:22
The system instruction or system prompt is not unifor- uniformly dealt with. I don't know if that's well understood. But OpenAI has this, like, user that is system that you can inject anywhere at any time, which is really fantastic.
- 37:35
But, um, Anthropic and Google require, like, a named system instruction that's a special one-time, like, at constructor time, um, instruction. So there's, uh, there's some differences. As much as best we can, we u- we unify.
- 37:52
All right. Any... How are folks doing on getting quick start going? I see a hand up. Is that a question or... Okay. I'll take... Maybe it's related to the quick start.
- 38:00
So one of the problems that I've seen with VAD is that it kind of struggles in a really noisy environment.
- 38:07
Oh, yeah. Great topic.
- 38:10
I was wondering if, um, there are any tricks you know to improve the, the VAD.
- 38:15
Yeah. So there's a question about noisy environments, which is, like, voice AI's kryptonite. Um, [chuckles] so the- with the VAD, no, not at the moment. Uh, but there are... Again, this is where, like, Pipecat is the assembler of all things.
- 38:28
What do you wanna plug in? Um, that you can run separately from the VAD. Uh, we found, like Krisp is one that's a partner of ours. They're have- they have fantastic noise cancellation.
- 38:41
You can run something outside of the loop that, uh, would actually clean up, like in the t- in Pipecat, it would be in the transport itself. So in that audio input, it would take, uh, the audio input and remove any ambient noise, so, like, chip bags opening or dogs barking.
- 38:55
But maybe more impressively, uh, human background voice. So it'll remove that from the feed. So you could be in this conference, and it picks up the primary speaker for the device, like, incredibly well.
- 39:06
At the moment, they're the only ones that I'm aware that know how to do that and do it that well. But it's, I mean, it's phenomenal. But you're right, the VAD is...
- 39:12
I mean, it was one of the biggest problems that we saw until we found Krisp, and they're fantastic.
- 39:18
Is that C-R-I-S-P?
- 39:20
K-R-I-S-P.
- 39:23
Okay.
- 39:23
So big props to the Krisp team.
- 39:26
Which speech, speech model are you guys using right now?
- 39:30
Well, we use, uh, we use all of them. Pipecat's open source, so we bring... We ha- I think options are Gemini, Multimodal Live, OpenAI real-time, and then, uh, AWS just launched a new one called Novasonic.
- 39:41
So we have those three, um, within Pipecat.
- 39:47
How, how, how... I mean, what's the... Is it the latest speakers
- 39:51
They're all pretty... They're all very much on par. Actually, well, they're all, they're all very similar. Um, I'm not gonna... I don't wanna, like, nitpick on all of the vendors here, but they're, I mean, they're...
- 40:01
They have strengths and weaknesses each 'cause it's still an emerging field. Um, but they're all... Latency-wise, that is not an issue. Latency is fantastic for all the providers. Yeah.
- 40:14
Thank you.
- 40:15
All right. Okay. Maybe Aleix will walk through a quick start. And why don't we... He's gonna just do some live coding here, and maybe this will help to understand what's, how this all works.
- 40:24
And then perhaps we, I stop chatting, and maybe you could grab me if you have questions and just do some heads down working time.
- 40:32
I don't have Vims.
- 40:34
Okay.
- 40:35
Yeah, I cannot type and [chuckles]
- 40:39
Teamwork.
- 40:40
Teamwork, yeah. Uh, I'll start from the very, very, from nothing, from scratch. Um, so this is a Python project. Um, actually, let me, let me try again. Yeah. This is a Python project.
- 40:53
The first thing we'll do is create an environment,
- 40:57
like a virtual environment that is called. I like to call it .env. That, that's how you create a virtual environment in, in, in Python. Um, a virtual environment will have-
- 41:09
Can we turn the lights up a little? It's hard to see the screen.
- 41:11
Oh, yeah.
- 41:12
What's that?
- 41:13
Your screen is hard to see.
- 41:14
Oh, it's hard to see. Um, how do I do that?
- 41:18
Or make it a bit bigger. Make the font bigger maybe. Try that.
- 41:22
Yeah, I guess. Could you use just, like, VS Code?
- 41:24
Better?
- 41:25
That's right. You're talking.
- 41:27
No.
- 41:28
Expert. Probably too.
- 41:29
It's like Emacs.
- 41:30
What's that?
- 41:31
Okay.
- 41:31
White.
- 41:31
Okay.
- 41:33
Can you s- do you-- can you change your theme to, like, white for the time being?
- 41:37
I guess. I only have one theme. Oh.
- 41:53
Maybe.
- 41:56
Emacs, yeah.
- 42:03
The only issue is I only have one theme. [chuckles] But, uh-
- 42:06
Is it better? Can you see it better?
- 42:08
Yeah.
- 42:09
Yeah.
- 42:09
Better?
- 42:10
Nice.
- 42:10
Okay. Yay. Okay. So we'll start with, um, uh... Yes, it's Emacs. You can judge me. Uh- [chuckles] ... I'm, I'm, I'm not gonna change. I have a few years only coding, so that's what it is.
- 42:25
Um, so I'm gonna create a requirements file. Sorry, I loaded... First thing, I did the virtual environment We did this, then we're gonna load it. Now you, we can start installing, uh, packages in, in this environment, like Python packages.
- 42:41
So the ones we have to do is, uh, Pipecat, of course. So I'm just creating a new file which has pipecat-ai, and Pipecat has a few options. So for this example, we're gonna use Daily, we're gonna use, uh, Google, and we're gonna use Silero.
- 43:01
Right? Silero is the VAD that we, we've been talking about. Um, the other thing we will do is we will load the envi- there's a package called python.env just to load the environment variables that we'll have, uh, in this, in here.
- 43:17
Okay? Um, that's it. One file. Now we're gonna... I'm gonna create, uh, an environment variable. I'm gonna just copy it from the,
- 43:29
from the kick start. It just, uh, oops. It's just a .env, and we can take a look at it. It... I will...
- 43:39
These are the, the API keys. We'll get rid of them after this workshop, so [laughs] But yeah, these are the... You just need two keys, Google API key, and just, uh, go to AI Studio and create your own one, and a Daily API key.
- 43:54
This one we already... This one you can copy. It's a bit long, but, uh, I don't know. It doesn't-
- 44:00
It's in the project.
- 44:01
Yeah, it's in the project. Yeah. Yeah, if you, if you are able to go to the, to the repo on GitHub, you will, you can just copy it from there.
- 44:09
All right. Next, we're gonna create a Python file. Let's call it, uh, bot.py. Again, empty file. Uh, first thing we'll do is typical, I think it's called name, uh, equals main.
- 44:27
No help [laughs] from an LLM. And then we do asyncio.run. Ah, a little bit of help. Asyncio.run, and we're gonna write a main, a main function. Function,
- 44:43
and then let's write the main function. All right. So now we start. So the first thing we, uh, we s- we, we said is we're gonna need a transport.
- 44:55
The transport input is like we're gonna, um, like the Dai- uh, Daily transport, we're gonna say. That's... I'm gonna speak to the, to the bot through the Daily transport, and that's what I'm gonna create.
- 45:06
And then we want... It's a transport for incoming audio from me talking, and then a transport, uh, for outputting what the, what the LLM will say. So I'm just gonna create a transport, um, and this is a Daily transport,
- 45:22
and it has a few, uh, arguments. It has a room URL. I'm just gonna create mine for now. Um, this is, uh, again, a public, public room that I will have to delete.
- 45:37
Uh, I don't need a token, and params.
- 45:43
Okay. And then the Daily params is like, what do we want this app-, uh, this transport to do? So we're gonna say that we want, uh, input enabled, which means get audio from the transport, and we also want to, [clears throat]
- 46:00
to send audio to the transport. Okay? Um,
- 46:06
all right. What else? Uh, it's complaining for something.
- 46:11
VAD.
- 46:11
Oh, yeah, and we also need a VAD analyzer, which is gonna be a Silero VAD analyzer. Um, so the transport is gonna be able to, uh, use this VAD analyzer to detect if the user has spoken or not.
- 46:27
You missed a name.
- 46:28
What's that?
- 46:29
You missed a name.
- 46:30
Oh, yeah. And this is gonna be AI engineer. There we go.
- 46:37
Okay, now we have the transport. Now we're gonna create the LLM. Uh, in this ca- it's Google, um, uh, Gemini Live, so I don't need to create an, uh, speech-to-text or a text-to-speech.
- 46:50
We just create, uh, the Gemini Live. And for that, I'll need to copy it for... 'cause I don't know that from memory. But, um...
- 47:00
Oops. That's in this file. Gemini bot. I just wanna copy these lines here. There we go.
- 47:11
All right. So this is my LLM, and again, it uses this Gemini multimodal live LLM service.
- 47:22
Um, Gemini multimodal live LLM service. That's gonna add my import. Okay. And now it needs a couple of things, a system ins- instruction, which is like what the, what the agent is gonna, is gonna do, and some tools.
- 47:36
The tools, I'm gonna skip them for now. So let's, let's do the system instruction. Again, I'm gonna copy it from somewhere. There it is.
- 47:46
This is like the prompt, like the main prompt of the... Well, let... Yeah.
- 47:52
All right. So the system instruction is, "You're a helpful assistant who can answer questions and use tools." For now, we're not gonna use any tools. Um, you know what?
- 48:02
Let me get rid of the tools. Just copy here for later. I'm gonna comment this out, and you are just the helpful assistant. Okay? So that's...
- 48:18
All right. Um, so no complaints here. All right. And now we just create the, [clears throat]
- 48:26
a pipeline. I'm gonna avoid storing the context 'cause I don't think we need it for now
- 48:34
And this is the pipeline. The pipeline just receives a list of, um, of processors or elements, and the first one is a transport.input. That's the input transport, so how we get audio from the, uh, from the Daily room in this case, the LLM and the transport.output.
- 48:59
All right. Now we need some... This just defines the pi- A pipeline also is another processor, so you could build a pipeline of pipelines of pipelines of pipelines. So you can build, uh, or you can plug and play, uh, as, as, um, the way you liked it.
- 49:15
So how do you run a pipeline? You need a task, what we call a pipeline task,
- 49:21
that receives a pipeline, and the pipeline task also has some params, which are called pipeline params.
- 49:30
Um, and we're gonna say... Oops. That we allow interruptions,
- 49:40
and I think that's enough.
- 49:44
Yeah.
- 49:44
And how do you run a task? Uh, you can create more than one pipeline task if you wanted. In this case, we just have one. Usually you just, you just have one.
- 49:53
Uh, you're gonna create a runner, and guess what? It's called pipeline runner. Um, it's pipeline runner, and then we just do await
- 50:05
runner run task, and some completions please. Pipeline
- 50:15
runner. All right. And I think that's it. Uh, we'll try it. Oh, OS, import OS, I think.
- 50:26
I think there's no more warnings. Oh, and I need to load the environment variables, which is this line here, load.env. I'm just copying it from another file.
- 50:40
Okay. And where do we get load.env? This is just a function that, um,
- 50:50
um, that imports, that imports the environment variable. All right. And yeah, let's, let's try. I'm just gonna open the... Oops. [clears throat]
- 51:05
I'm just gonna open the terminal here, and I'm just gonna run it. I think we call it bot.py.
- 51:14
Uh, no model. Oh, maybe I need to install the requirements. I forgot this step.
- 51:26
There it is. Okay. So initia- at the beginning I, uh, wrote that file requirements.text, which has, uh, had a bunch of, uh... Well, again, just a few requirements, but I forgot to, to install them.
- 51:49
In the meantime, I'm just gonna go to the Daily room that I just pointed the bot to.
- 52:07
Uh, no video. Okay. All right. So that's, uh, right now it's just me in that, in that room, so... And now we just have to wait for this to, to finish, and hopefully the bot will join the room and we'll be able to talk to it.
- 52:27
Hopefully.
- 52:32
Yeah. How important is, um, like Daily as part of this flow? Like that room component, like is it interchangeable?
- 52:41
It is inter- Yeah, it's... This is because, uh, we're using the Daily transport, and the Daily transport just connects to a Daily room.
- 52:49
Okay.
- 52:49
So, but you could have a, a WebSocket transport and then use Twilio with a phone number and Twilio being connected to that.
- 52:57
Gotcha.
- 52:57
If we have time, we can even try that. Um, so I think-
- 53:01
What's the problem with SmallWebRTC transport? Can you talk about SmallWebRTC transport and why you didn't use it?
- 53:06
You wanna, you wanna talk about that?
- 53:09
Yeah, sure.
- 53:09
Oh.
- 53:09
Yeah.
- 53:09
Yeah, I'll wait. [chuckles] I'll just...
- 53:11
So we als- uh, in Pipecat we also have added, um, based off of the AIORTC Python package, which is how, uh, WebRTC package in Python. We've added a, a new transport called SmallWebRTC transport.
- 53:25
It is a peer-to-peer WebRTC communication that's free, so it's separate from any vendor. Uh, though the one downside is that it requires a turn server, which we... You bring your own, so we, [chuckles] we didn't...
- 53:37
You know, we weren't prepared for that for the conference, and also just the conference Wi-Fi makes that a little challenging. But normally, if you're running any of the, any of the, um...
- 53:45
We call them foundational examples in Pipecat. Think of them as the, like, essential, um, examples that show how to do very specific functions. There's probably about 100 of them in Pipecat.
- 53:55
But one by one it shows you how to, like, record or add an SDT or push frames or show images or sync images and, and sound. Those all use the peer-to-peer WebRTC transport.
- 54:06
So we, we would have loved to have used that. You wouldn't need a key. But unfortunately, firewall rules have trumped.
- 54:13
All right. Uh, so I'm just running the bot and see how it fails, because it has to fail the first time.
- 54:26
Yeah, this is the mass th-th-there 'cause there's a bunch of the, um, Python packages, and Python just decides to take, uh, a time to load them. But you see how easy it was to write, um-
- 54:43
Like an agent, like a voice agent with Gemini Live, uh, if it work, it, it just a few lines of code, uh, that we wrote in... I don't know how long it took me, but, uh, maybe like five, 10 minutes.
- 54:58
Um, yeah. Are there any questions [chuckles] on the example or-
- 55:04
It worked here.
- 55:04
What's that?
- 55:05
It worked.
- 55:06
It worked?
- 55:06
Working, yeah. It worked.
- 55:07
What worked?
- 55:09
The bot.
- 55:09
The bot worked?
- 55:10
Yes.
- 55:10
Okay. All righty. [chuckles]
- 55:14
Great.
- 55:15
All right. Nice.
- 55:17
You need friends with good Wi-Fi.
- 55:19
Yeah. [laughs]
- 55:23
There was a couple of things that popped up there with the words later in it. Like where are you at in terms of production ready and stuff like that for commercial use?
- 55:31
Copy that.
- 55:33
Uh, we have-- I, I don't know the actual number of customers, but, I mean, Pipecat probably serves hundreds of thousands of calls a day. I don't know. A lot.
- 55:41
Quinn, you probably have a better idea.
- 55:44
Oh, yeah. I mean, Pipecat is used by some very large companies in production. Uh, and people are contributing to it from NVIDIA, AWS, uh, OpenAI, Google, uh, lots of, lots of big companies.
- 55:57
Yeah. There's one thing we didn't mention about Pipecat is that what you see now in the screen, this runs on the server side, but we do have client SDKs for Android, iOS, JavaScript, and React, and I think that's about it.
- 56:14
But, uh, Ragnar, even a, a C++ client, um, uh, if you want. Um, so yeah. So that's the server side, but you can plug your, your client and connect to the, to the agent on your, on your phone.
- 56:30
And they're all WebRTC connections or like-
- 56:32
That would be-- It-- That depends on the transport you use. But yeah, you could, you could have your client connect to a Daily or we support LiveKit as well, but to a Daily room.
- 56:44
We like Daily because we are [chuckles] working Daily. But, uh, you connect, you can connect to a Daily room, and then the bot would connect or the agent will connect to the Daily room as well, and then that's the transport, the WebRTC transport.
- 56:56
Yeah. I think there were questions there. I can't see. [background chattering]
- 57:14
Uh, say it again.
- 57:15
So are there other ways to test the bot, like other than talking to the-
- 57:21
Yes. Yes, there is. Um, actually, uh, for the previous version, um, I just hacked together a thing ca- that wa- that I call release evals, which is a bot talking to a bot.
- 57:34
And what it does is I put this bot, uh, up and then it joins a Daily room. And then I have a, an eval bot, and the eval bot, um, what it's gonna do, it has a prompt, which is ask a simple addition.
- 57:50
Okay? And then that eval bot is gonna connect to the room. It's gonna add, "What is two plus two?" And then the other bot is gonna reply, "Two plus two is four."
- 58:00
And the eval bot, the LLM, uh, [clears throat] it checks if the answer of the user is correct, and the user in this case is another LLM. So it verifies. It's like an end-to-end.
- 58:12
The good thing is we, we run the-- We used to run like more than a hundred examples every release just to make sure they work. So I just got tired of it 'cause it's very painful and very slow.
- 58:24
So we have this, uh, eval bot or eva-- uh, release evals that are gonna test each service. Like we test Gemini Live, we test Cartesia, Deep Gram, like all the services like end-to-end, and then the bots basically talk to each other with voice.
- 58:41
That's the, that's the, the nice thing. So yeah.
- 58:45
Okay, may- Oh, is this on? Maybe real quick just to show for those that didn't see it, it is working. Hey, can you tell me a joke?
- 58:54
Why don't scientists trust atoms? Because they make up everything. [audience applauding]
- 59:01
Which if you build Pipecat, I've heard that joke probably, I mean, not like five thousand times. Like for-- You can even try to seed it with something different, but it still tells the same joke.
- 59:10
Okay. I will try to come up with a new joke next time.
- 59:11
What-- Yeah. Why do, why do you always say the same joke?
- 59:17
That's an interesting question. Why do you think people keep telling the same jokes?
- 59:22
I don't know. You tell me.
- 59:28
From my search, there appear to be several reasons why people repeat jokes. [audience laughing] Enjoyment and reinforcement. People repeat things they find funny because they want to re-experience the good feeling associated with laughter.
- 59:39
It feels good, and repeating it is a way to try and recreate that sensation. Memory aid.
- 59:45
Okay. Okay, that's enough.
- 59:45
Repeating something can help you remember.
- 59:47
Yeah. Um-
- 59:49
Is there anything else I can help you with today?
- 59:51
No, thank you. That, that was it.
- 59:53
Thanks.
- 59:53
Thank you so much.
- 59:54
Well, just to show, there was a question about interruptions. We could just have it... Like my favorite is to ask it to tell you like a really long story and then interrupt it.
- 1:00:01
So can you tell me a really long and really long story?
- 1:00:06
Okay, I can do that. Here's a story, and feel free to interrupt whenever you like. Once upon a time-
- 1:00:12
Okay. Actually, tell me that new joke.
- 1:00:14
Following the clues, she discovered-
- 1:00:16
Nope. Hey, tell me that new joke.
- 1:00:17
Oh, you'd like to... Why don't scientists trust atoms? Because they make up everything. Okay, here's one-
- 1:00:24
Again? What-- That was the same joke. [laughs] [laughs]
- 1:00:28
That was the same joke. All right. All right.
- 1:00:31
That was it.
- 1:00:34
No. Well, I find like a lot of conversational agents, like they choke based on when you pause talking, right? Like that's the turn-
- 1:00:44
Oh
- 1:00:52
So I think the questions asked during this workshop could map out like years of work. So this is like the-- another one of those fantastic cutting-edge things. So again, back to like human evolution.
- 1:01:05
We all know and when we talk... Actually, it's even hard for humans to talk to not speak over each other. So the way that it works mechanically is when the user stops speaking, the VAD has a timeout.
- 1:01:14
You tell it and program it, wait, let's say one second, point eight seconds, half second, whatever feels natural. And you're trying to balance low latency response with giving the user enough time to speak.
- 1:01:25
It's a really hard thing, and it's one of the biggest complaints is that agents will speak over the human. So if you're-- Let's say you're building an interview bot, like you're using, um, like Tavis, one of their digital twins.
- 1:01:36
You wanna have like a, a real, like, likeness, and you wanna speak to it.
- 1:01:41
You may take time to think 'cause sometimes you have to take time to think, and that's a really difficult thing for bots to do 'cause again, it's driven by like a simple stop speaking algorithm.
- 1:01:51
So this is a new, uh, I guess it's like an emerging, uh, field of models, which is looking at semantic, uh, end of turn. So driven off of things like, um,
- 1:02:03
like speech filler words, uh, pauses, uh, intonation. So things in the audio realm and also things in the text-based realm. So just looking at context. So we've actually started, uh...
- 1:02:15
We're one of many that are doing this, I think. We c- we launched a model. Uh, if you look at it on GitHub, it's under smart-turn. It's a native audio in, uh, classifier that runs an inference on the in- input audio, and it simply outputs either complete or incomplete.
- 1:02:31
And the way Pipecat uses this is that if you get an incomplete response, we can dynamically adjust the VAD timeout. So we can tell the Pipecat bot, "Okay, he's, you know, he or she is not done speaking.
- 1:02:42
Let's actually move the-- Let's give three seconds to complete the thought," and if it's not done, then the bot will actually respond. So you can create a little bit of like dynamic interaction there.
- 1:02:52
And that's one of the first things. Uh, I'm sure Goo- the Google team is working on th- similar things. I know OpenAI is, and all the STT vendors are, are also looking at their own thing.
- 1:03:01
So I'd say right now it is very much an unsolved problem. But I would imagine, given how fast things are going in the next 12 months, we'll have great solutions that will make it even more natural to talk to a bot.
- 1:03:13
It's a good question.
- 1:03:20
Any more questions?
- 1:03:21
Any questions?
- 1:03:23
Well, uh, actually, I'm kind of wondering like, uh,
- 1:03:27
like is there a way to see the transcription of the text as it's happening versus only-
- 1:03:32
Oh, yeah. Yeah, yeah. One of-- Uh, this is actually back to the... Well, for-- This is specific to Pipecat but also, um, like Gemini Live will output audio and text and other speech-to-speech LLMs do this.
- 1:03:46
Uh, Pipecat offers in terms of its, again, orchestration role when you get a, uh... Actually, it's going to be specific to TTS provider. Um, many TT- There are great TTS providers that do word and timestamp synchronization.
- 1:04:00
So they'll give pairs. They call them like alignment pairs. So if you're using a Cartesia or an ElevenLabs or Rime, they all output these pairs. One of the really cool things with Pipecat is that the TTS services output not only the audio stream but also the text stream.
- 1:04:16
So they'll output text frames, TTS text frames we call them in Pipecat. And if you place, uh, we have-- In terms of how the client software works, there is, uh, like an observer role where you can actually watch.
- 1:04:27
There's a process that can watch things that happen in the pipeline and emit events. So we've instrumented that for the clients so that whenever you see those text frames move through the transport, you can get synchronized word and audio output.
- 1:04:40
So in your client, if you wanted to have word by word output synchronized to the audio, you can do that with Pipecat. And it's as simple as just adding an event.
- 1:04:48
I think you listen to like bot TTS text output or on bot TTS text, and it will give you the synchronized output.
- 1:04:56
If I wanted to build a fully offline voice agent, what box in that pipeline would be the hardest or toughest to do well?
- 1:05:06
Fully offline. Um, well, they're all doable. There are great models. I think it really depends on what your bot needs to accomplish. Um, a lot of the state-of-the-art models to do all the best and smartest things need to have some...
- 1:05:17
Like, they're going to be run like on-prem or in, in the cloud. Um, but if you have-- And a lot of j- bots do jobs. Like, if you wanted to build a, like a restaurant reservation one like I referenced earlier, it's a very simple job.
- 1:05:29
You could probably run it with some version of Llama running locally. Um, there are great local... And something, again, Quinn has been experimenting with, uh, a lot of great local models.
- 1:05:40
Like, um, Whisper has challenges, you know. It, I mean, it's, it has a lot, uh, it has some challenges, uh, as an open source model for, uh, STT, but there are good and emerging TTS services.
- 1:05:53
So, you know, I, I-- Things are only as good as the input, and we've actually seen this with some of the speech-to-speech models that sometimes they mistranscribe. So you really need...
- 1:06:01
I mean, it, it's, you know, there-- Every part is critical, but if you can't transcribe the speech really well, nothing really matters. Like, it has to understand you. And having like disfluencies or like hallucinated responses or even just inaccurate responses kind of breaks everything down.
- 1:06:15
So things mostly start at, at the STT. So maybe that's the hardest. I don't know if there are a lot of good open source options for that right now.
- 1:06:21
You said there's someone on your team looking at that?
- 1:06:23
I don't know. We don't, we're not doing anything in the STT world. No, no.
- 1:06:28
No. It-- That's a whole different ballgame. Good question, though.
- 1:06:32
Just made me realize we could have used local models [chuckles] and avoid this.
- 1:06:37
We could have. Yeah.
- 1:06:37
This mess. [laughs]
- 1:06:38
Well, we're, we're partnering with the, the Google team.
- 1:06:41
Yeah, yeah. As a... Yeah, exactly. Yeah.
- 1:06:45
Has anyone looked at any of the sample projects and had questions? There's a lot of interesting things there. If any of this has, like, interested you, we do have a Discord.
- 1:06:54
You're welcome to get on it. Um, you can find us at pipecat.ai And find our Discord there. You can ask questions. Um, there's some really cool stuff with Gemini that can be done.
- 1:07:05
There, uh, in particular in the Pipecat repo, we built, uh, like, I don't know if you know the game Catch Phrase, where you describe a word and something, you know, guesses it.
- 1:07:13
We built a version of that. We had to brand it something else called Word Wrangler, and you as the human, you describe a word, and then you have the AI agent try to answer it.
- 1:07:22
So we built a client-server version of that, which I linked to in the repo, and then we have one that's a phone-based one that's, I think, particularly sophisticated and interesting 'cause you might think like, "How the hell would I build this with a speech-to-speech model?"
- 1:07:34
We actually use two Gemini agents in the same call, and we use a parallel pipeline where one agent is the host giving out the, the questions to the human user.
- 1:07:45
The other is the guesser, and we ha-- you know, kind of limit the audio flow so that the guesser, the AI player, can only hear the user. So there's a bunch of really interesting things getting into the, majorly into the weeds of some of the powers of, um, Pipecat.
- 1:07:58
But it also speaks to the strength of having just native audio input being really, really help- helpful. So I'd recommend checking those out. Um, really cool, easy demos to run.
- 1:08:07
One's Twilio. The other is, again, a client server. I think it's like a React Next.js project.
- 1:08:16
What's that? Word Wrangler. Word Wrangler? Yeah. Yeah. I mean, we could, we could run the Word Wrangler client app. It's actually just on the web.
- 1:08:26
Test.
- 1:08:28
Welcome to Word Wrangler. I'll, I'll try to guess the words you describe. Remember, don't say any part of the word itself. Ready? Let's go.
- 1:08:39
Uh, I'm gonna skip to something easier. Okay, this is something you take pictures with. It's on your phone.
- 1:08:48
Is it camera?
- 1:08:50
All right. This is a field, uh, related to the study of languages, I think.
- 1:08:56
Is it linguistics?
- 1:08:57
All right. This is a game with a yellow ball you play with rackets. You hit the ball over the net.
- 1:09:03
Is it tennis?
- 1:09:05
All right. This is a, a round dessert with chocolate chips sometimes and other fun goodies.
- 1:09:14
Is it cookie?
- 1:09:14
It's really good even when I'm bad at giving answers, so pretty cool. This is with the-- built with Gemini Live. But again, just an example of things you can build with, uh, with voice AI, so cool, unique interactions.
- 1:09:31
All right. I think that's about it. Thanks, everybody. [upbeat music]