|
1 | 1 | # LivePaint
|
2 | 2 |
|
3 |
| -This is an example project demonstrating how to build a realtime data app using LiveKit. |
| 3 | +This LiveKit example project is a realtime drawing game where players compete to complete a drawing prompt as fast as possible, while being judged by a realtime AI agent that oversees the whole game. |
4 | 4 |
|
5 |
| -In this example, we build a realtime drawing game where players compete to complete a drawing prompt as fast as possible, while being judged by an AI agent that oversees the whole game. |
| 5 | +It demonstrates the use of LiveKit's [realtime data messages](https://docs.livekit.io/home/client/data/messages), [room metadata](https://docs.livekit.io/home/client/data/room-metadata/), [RPC](https://docs.livekit.io/home/client/data/rpc/), [participant management](https://docs.livekit.io/home/server/managing-participants/), [token generation](https://docs.livekit.io/home/server/generating-tokens/), and [realtime audio chat](https://docs.livekit.io/home/client/tracks/) in a real-world app built on the LiveKit [JS SDK](https://github.com/livekit/client-sdk-js), [React Components](https://github.com/livekit/components-js), [Python agents SDK](https://github.com/livekit/agents), and [Python Server API](https://github.com/livekit/python-sdks). |
6 | 6 |
|
7 |
| -This example demonstrates the use of [realtime data messages](https://docs.livekit.io/home/client/data/messages), [room metadata](https://docs.livekit.io/home/client/data/room-metadata/), [RPC](https://docs.livekit.io/home/client/data/rpc/), [participant management](https://docs.livekit.io/home/server/managing-participants/), [token generation](https://docs.livekit.io/home/server/generating-tokens/), and [realtime audio chat](https://docs.livekit.io/home/client/tracks/) in a real-world app built on the LiveKit [JS SDK](https://github.com/livekit/client-sdk-js), [React Components](https://github.com/livekit/components-js), [Python agents SDK](https://github.com/livekit/agents), and [Python Server API](https://github.com/livekit/python-sdks). |
8 |
| - |
9 |
| -Try it live at [https://live-paint.vercel.app](https://live-paint.vercel.app)! |
| 7 | +Play live at [https://paint.livekit.io](https://paint.livekit.io)! |
10 | 8 |
|
11 | 9 | ## Architecture
|
12 | 10 |
|
| 11 | +This is a short overview of how this game was built. The entire codebase is also annotated with comments that go into more detail. The `agent` directory contains the code for the realtime agent (built on [LiveKit Agents](https://docs.livekit.io/agents)). The `web` directory contains the code for the game frontend (built on [Next.js](https://nextjs.org/) with [LiveKit React Components](https://github.com/livekit/components-js)). |
| 12 | + |
13 | 13 | ### Rooms & Participants
|
14 | 14 |
|
15 | 15 | Each game is hosted in a single [LiveKit room](https://docs.livekit.io/home/client/connect) where each player is a standard participant. The room is reused between games, so the same group of players can complete multiple games back-to-back.
|
@@ -58,37 +58,56 @@ The agent is responsible for judging each player's drawing. It runs a single loo
|
58 | 58 |
|
59 | 59 | Realtime chat is enabled within each room by [publishing the local microphone](https://docs.livekit.io/home/client/tracks/publish/) and [rendering the room audio](https://docs.livekit.io/reference/components/react/component/roomaudiorenderer/).
|
60 | 60 |
|
61 |
| -## Ideas / What's Next? |
| 61 | +## Ideas & What's Next? |
62 | 62 |
|
63 |
| -If you'd like to learn to build with LiveKit, try to implement the following feature ideas or invent your own: |
| 63 | +Learn to build with LiveKit by adding one of the following features, or come up with your own! |
64 | 64 |
|
65 | 65 | - Add a scoreboard that shows how many wins each player has racked up
|
66 | 66 | - We think [participant attributes](https://docs.livekit.io/home/client/data/participant-attributes/) is a great place to keep track of this
|
67 | 67 | - Have the AI agent make its guesses and announce winners with realtime audio as well as text
|
68 |
| - - We'd try using a [Text-To-Speech plugin](https://docs.livekit.io/agents/plugins/#text-to-speech-tts) |
69 |
| - - Consider having the agent publish a different track to each participant, so they don't need to hear the guesses for everyone else in realtime |
70 |
| -- Add a room list on the front page that shows open rooms and lets you join one |
71 |
| - - Try the [List Rooms](https://docs.livekit.io/home/server/managing-rooms/#list-rooms) Server API |
| 68 | + - We'd try using a LiveKit [Text-To-Speech (TTS) plugin](https://docs.livekit.io/agents/plugins/#text-to-speech-tts) |
| 69 | + - To make it perfect, have the agent [publish](https://docs.livekit.io/home/client/tracks/publish/) a different audio track to each participant so they can hear the guesses for everyone else in realtime |
| 70 | +- Add a room list on the front page that shows open rooms and lets you join any of them |
| 71 | + - We'd use the [List Rooms](https://docs.livekit.io/home/server/managing-rooms/#list-rooms) Server API in a Next.js API route |
72 | 72 | - Add support for multiple brush sizes and colors
|
73 |
| - - You'll probably want to extend the data format for `Line` to record brush size and color |
74 |
| - |
| 73 | + - You'll need to extend the data format for `Line` to record brush size and color |
75 | 74 |
|
76 | 75 | ## Development & Running Locally
|
77 | 76 |
|
78 |
| -Run the agent: |
| 77 | +You'll need a LiveKit instance to run this project, either from [LiveKit Cloud](https://cloud.livekit.io) or [Self-hosted](https://docs.livekit.io/home/self-hosting/local/). |
79 | 78 |
|
80 |
| -``` |
| 79 | +### Running the Agent |
| 80 | + |
| 81 | +First add `agent/.env` with LIVEKIT_API_KEY, LIVEKIT_API_SECRET, LIVEKIT_URL, and OPENAI_API_KEY. |
| 82 | + |
| 83 | +Then run the following commands to install dependencies: |
| 84 | + |
| 85 | +```shell |
81 | 86 | cd agent
|
82 | 87 | python -m venv venv
|
83 | 88 | source venv/bin/activate
|
84 | 89 | pip install -r requirements.txt
|
| 90 | +`` |
| 91 | + |
| 92 | +Finally, boot the agent: |
| 93 | + |
| 94 | +```shell |
85 | 95 | python main.py dev
|
86 | 96 | ```
|
87 | 97 |
|
88 |
| -Run the site: |
| 98 | +### Running the Site |
89 | 99 |
|
90 |
| -``` |
| 100 | +First add `web/.env.local` with LIVEKIT_API_KEY, LIVEKIT_API_SECRET, and LIVEKIT_URL. |
| 101 | + |
| 102 | +Then run the following commands to install dependencies: |
| 103 | + |
| 104 | +```shell |
91 | 105 | cd web
|
92 | 106 | pnpm install
|
| 107 | +``` |
| 108 | + |
| 109 | +Finally, start the site: |
| 110 | + |
| 111 | +```shell |
93 | 112 | pnpm dev
|
94 | 113 | ```
|
0 commit comments