Voice assistant backend powered by LiveKit Agents with OpenAI Realtime voice and built‑in noise cancellation. Conversation events are logged to Supabase for later analysis.
- Realtime voice assistant using an OpenAI voice model
- Built‑in noise cancellation (BVC)
- Structured conversation logging to Supabase
- Dockerized and ready for LiveKit Cloud deployment
- LiveKit hosts the realtime audio room and runs this Agent.
- Agent (this repo) connects to LiveKit, handles audio and conversation logic, calls OpenAI, and writes logs.
- OpenAI provides the realtime voice model and reasoning.
- Supabase stores structured conversation logs in a Postgres table.
src/agent.py– LiveKit Agent entrypoint and Supabase loggingDockerfile– Container image definition for LiveKit Cloudlivekit.toml– LiveKit CLI/Cloud configuration (subdomain, agent ID)requirements.txt– Python dependencies
- Python 3.11+ (for local development)
- LiveKit CLI (for deploys): https://docs.livekit.io/cloud/agents/deploy/
- Supabase project with a table to receive logs
- OpenAI API key (recommended) for the OpenAI plugin
Set these either in a local .env file or in your deployment environment:
| Variable | Description |
|---|---|
SUPABASE_URL |
Supabase project URL |
SUPABASE_KEY |
Service role or anon key with INSERT permission into the log table |
OPENAI_API_KEY |
API key used by livekit-plugins-openai |
LIVEKIT_URL |
LiveKit server URL for local runs (not required on LiveKit Cloud) |
LIVEKIT_API_KEY |
LiveKit API key for local runs (LiveKit Cloud injects this automatically in deployments) |
LIVEKIT_API_SECRET |
LiveKit API secret for local runs (LiveKit Cloud injects this automatically in deployments) |
Important: Supabase is initialized lazily at runtime. During the Docker build we run python src/agent.py download-files to prefetch assets. Missing SUPABASE_* variables will not break the image build; logging is simply skipped until credentials are provided at runtime.
Conversation events are inserted into the Supabase table test-speech-interaction with the following columns:
room_number(text) – Room identifier from LiveKitmodi(text) – Experimental condition / mode labelparticipant_id(text) – Participant identifierrole(text) – Speaker role (e.g.user,assistant)message(text) – Message content (transcript)interrupted(boolean) – Whether the message was interruptedts(timestamptz) – Event timestamp
Example SQL to create the table in Supabase:
create table if not exists public."test-speech-interaction" (
room_number text,
modi text,
participant_id text,
role text,
message text,
interrupted boolean,
ts timestamptz default now()
);-
(Optional but recommended) Create and activate a virtual environment:
python -m venv .venv .venv\Scripts\activate # Windows PowerShell
-
Create a
.envfile in the repo root:SUPABASE_URL=... SUPABASE_KEY=... OPENAI_API_KEY=... # For local runs (if not using Cloud): LIVEKIT_URL=... LIVEKIT_API_KEY=... LIVEKIT_API_SECRET=...
-
Install dependencies and start the Agent:
pip install -r requirements.txt python src/agent.py start
-
(Optional) Pre‑download plugin assets (same step used in the Docker build):
python src/agent.py download-files
Once the Agent is running and connected to a LiveKit room, join the room with a LiveKit client (e.g. a web or mobile app) to talk to the assistant. Logged conversation events should appear in your Supabase table.
-
Install and log in to the LiveKit CLI (see the LiveKit docs linked above).
-
Ensure
livekit.tomlis configured with your subdomain and Agent settings. -
Deploy the Agent:
lk agent deploy
This builds the Docker image (using the provided Dockerfile), uploads it, and deploys your Agent. After code changes, run lk agent deploy again to push a new version.