Skip to content

Commit 3521bef

Browse files
Update starter to use new turn detector model (#51)
* Update starter to use new turn detector model * update method name * remove unnecessary pp * update @livekit/agents dependency version * Remove vad from session initialization Remove vad from session initialization. --------- Co-authored-by: Chenghao Mou <chenghao.mou@livekit.io>
1 parent 7101d27 commit 3521bef

3 files changed

Lines changed: 9 additions & 26 deletions

File tree

README.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ lk app env -w -d .env.local
9494

9595
## Run the agent
9696

97-
Before your first run, you must download certain models such as [Silero VAD](https://docs.livekit.io/agents/logic/turns/vad/) and the [LiveKit turn detector](https://docs.livekit.io/agents/logic/turns/turn-detector/):
98-
99-
```console
100-
pnpm run download-files
101-
```
102-
10397
To run the agent during development, use the `dev` command:
10498

10599
```console

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@
3434
"vitest": "^4.1.4"
3535
},
3636
"dependencies": {
37-
"@livekit/agents": "^1.4.3",
38-
"@livekit/agents-plugin-livekit": "^1.4.3",
39-
"@livekit/agents-plugin-silero": "^1.4.3",
37+
"@livekit/agents": "^1.4.7",
4038
"@livekit/plugins-ai-coustics": "^0.2.14",
4139
"dotenv": "^17.4.1",
4240
"zod": "^3.25.76"

src/main.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { ServerOptions, cli, defineAgent, inference, voice } from '@livekit/agents';
2-
import * as livekit from '@livekit/agents-plugin-livekit';
3-
import * as silero from '@livekit/agents-plugin-silero';
42
import { audioEnhancement } from '@livekit/plugins-ai-coustics';
53
import dotenv from 'dotenv';
64
import { fileURLToPath } from 'node:url';
@@ -11,14 +9,7 @@ import { Agent } from './agent';
119
// when running locally or self-hosting your agent server.
1210
dotenv.config({ path: '.env.local' });
1311

14-
interface ProcessUserData {
15-
vad: silero.VAD;
16-
}
17-
18-
export default defineAgent<ProcessUserData>({
19-
prewarm: async (proc) => {
20-
proc.userData.vad = await silero.VAD.load();
21-
},
12+
export default defineAgent({
2213
entry: async (ctx) => {
2314
// Set up a voice AI pipeline using OpenAI, Cartesia, Deepgram, and the LiveKit turn detector
2415
const session = new voice.AgentSession({
@@ -36,16 +27,16 @@ export default defineAgent<ProcessUserData>({
3627
voice: '9626c31c-bec5-4cca-baa8-f8ba9e84c8bc',
3728
}),
3829

30+
// Turn detection determines when the user is speaking and when the agent should respond.
31+
// The LiveKit audio turn detector is a multimodal model that encodes the user's audio
32+
// directly to predict end of turn. It's built into the SDK (no extra plugin) and
33+
// AgentSession supplies the required VAD automatically.
34+
// See more at https://docs.livekit.io/agents/logic/turns/turn-detector/
3935
turnHandling: {
40-
// VAD and turn detection are used to determine when the user is speaking and when the agent should respond
41-
// See more at https://docs.livekit.io/agents/build/turns
42-
turnDetection: new livekit.turnDetector.MultilingualModel(),
36+
turnDetection: new inference.TurnDetector(),
4337
// Allow the LLM to generate a response while waiting for the end of turn
44-
preemptiveGeneration: {
45-
enabled: true,
46-
},
38+
preemptiveGeneration: { enabled: true },
4739
},
48-
vad: ctx.proc.userData.vad,
4940
});
5041

5142
// Start the session, which initializes the voice pipeline and warms up the models

0 commit comments

Comments
 (0)