In this quickstart, we’ll create a simple conversational bot that greets users when they join and exits when they leave. This example demonstrates the core components of a Pipecat application with a streamlined setup.
python -m venv envsource env/Scripts/activate # If using Git Bash# OR.\env\Scripts\activate # If using Command Prompt# OR.\env\Scripts\Activate.ps1 # If using PowerShell
You’ll see a URL (typically http://localhost:7860) in the console output. Open this URL in your browser to join the session. The bot will automatically join, greet you, and then disconnect.
Let’s examine the key components of 01-say-one-thing.py:
Copy
# The `run_example()` function receives a transport which can be a# SmallWebRTCTransport, a DailyTransport or a FastAPIWebsocketTransport. The# global variable `transport_params` defines the transport settings, in this case# `audio_out_enabled=True` which means the example will send audio out (and you# will hear it).# Initialize Cartesia's text-to-speech service# Using a pre-selected British female voice# You can find other voices at https://play.cartesia.ai/voicestts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), voice_id="79a125e8-cd45-4c13-8a67-188112f4dd22", # British Reading Lady)# Create PipelineTask containing the Pipeline# The Pipeline processes text into speech and play it# 1. tts: Converts text messages into audio# 2. transport.output(): Sends audio into the WebRTC sessiontask = PipelineTask(Pipeline([tts, transport.output()]))# When the client connects:# - Generate a greeting message# - Queue it for text-to-speech conversion# - Queue an EndFrame to shut down the pipeline when done@transport.event_handler("on_client_connected")async def on_client_connected(transport, client): await task.queue_frames([TTSSpeakFrame(f"Hello there!"), EndFrame()])# Create a pipeline runner and run the pipeline taskrunner = PipelineRunner(handle_sigint=False)await runner.run(task)