Skip to content

Commit a34c18b

Browse files
committed
Uplift AI TTS
1 parent 4677d33 commit a34c18b

File tree

11 files changed

+1151
-1
lines changed

11 files changed

+1151
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,6 @@ docs
189189
# vscode workspace config
190190
agents-js.code-workspace
191191

192-
examples/src/test_*.ts
192+
examples/src/test_*.ts
193+
194+
.claude

examples/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@livekit/agents-plugin-cartesia": "workspace:*",
3333
"@livekit/agents-plugin-neuphonic": "workspace:*",
3434
"@livekit/noise-cancellation-node": "^0.1.9",
35+
"@livekit/agents-plugin-upliftai": "workspace:^",
3536
"@livekit/rtc-node": "^0.13.11",
3637
"livekit-server-sdk": "^2.13.3",
3738
"zod": "^3.23.8"

examples/src/upliftai_agent.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
import {
5+
type JobContext,
6+
type JobProcess,
7+
WorkerOptions,
8+
cli,
9+
defineAgent,
10+
metrics,
11+
voice,
12+
} from '@livekit/agents';
13+
import * as livekit from '@livekit/agents-plugin-livekit';
14+
import * as openai from '@livekit/agents-plugin-openai';
15+
import * as silero from '@livekit/agents-plugin-silero';
16+
import * as upliftai from '@livekit/agents-plugin-upliftai';
17+
import { BackgroundVoiceCancellation } from '@livekit/noise-cancellation-node';
18+
import { fileURLToPath } from 'node:url';
19+
20+
export default defineAgent({
21+
prewarm: async (proc: JobProcess) => {
22+
proc.userData.vad = await silero.VAD.load();
23+
},
24+
entry: async (ctx: JobContext) => {
25+
const vad = ctx.proc.userData.vad! as silero.VAD;
26+
27+
const agent = new voice.Agent({
28+
vad, // openai stt needs this
29+
instructions:
30+
'You are a helpful voice assistant that shares some jokes. Always respond in Urdu Nastaliq script. Normalize responses for narration.',
31+
});
32+
33+
const session = new voice.AgentSession({
34+
vad, // VAD is required here for OpenAI STT
35+
stt: new openai.STT({
36+
model: 'gpt-4o-transcribe',
37+
language: 'ur',
38+
}),
39+
tts: new upliftai.TTS(),
40+
llm: new openai.LLM({
41+
model: 'gpt-4o-mini',
42+
}),
43+
turnDetection: new livekit.turnDetector.MultilingualModel(),
44+
});
45+
46+
const usageCollector = new metrics.UsageCollector();
47+
48+
session.on(voice.AgentSessionEventTypes.MetricsCollected, (ev) => {
49+
metrics.logMetrics(ev.metrics);
50+
usageCollector.collect(ev.metrics);
51+
});
52+
53+
await session.start({
54+
agent,
55+
room: ctx.room,
56+
inputOptions: {
57+
noiseCancellation: BackgroundVoiceCancellation(),
58+
},
59+
});
60+
61+
session.generateReply({
62+
instructions: 'Greet the user',
63+
});
64+
},
65+
});
66+
67+
cli.runApp(new WorkerOptions({ agent: fileURLToPath(import.meta.url) }));

plugins/upliftai/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2025 LiveKit, Inc.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
-->
6+
7+
# @livekit/agents-plugin-upliftai
8+
9+
UpliftAI TTS plugin for LiveKit Node Agents.
10+
11+
## Installation
12+
13+
```bash
14+
npm install @livekit/agents-plugin-upliftai
15+
```
16+
17+
## Usage
18+
19+
```typescript
20+
import { TTS } from '@livekit/agents-plugin-upliftai';
21+
22+
// Initialize TTS with your API key
23+
const tts = new TTS({
24+
apiKey: 'your-api-key', // or set UPLIFTAI_API_KEY environment variable
25+
voiceId: 'v_meklc281', // optional, defaults to v_meklc281
26+
});
27+
28+
29+
## Configuration
30+
31+
### Environment Variables
32+
33+
- `UPLIFTAI_API_KEY`: Your UpliftAI API key
34+
- `UPLIFTAI_BASE_URL`: Base URL for the UpliftAI API (defaults to `wss://api.upliftai.org`)
35+
36+
## License
37+
38+
Apache-2.0
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
3+
*/
4+
{
5+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
6+
7+
/**
8+
* Optionally specifies another JSON config file that this file extends from. This provides a way for
9+
* standard settings to be shared across multiple projects.
10+
*
11+
* If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains
12+
* the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
13+
* resolved using NodeJS require().
14+
*
15+
* SUPPORTED TOKENS: none
16+
* DEFAULT VALUE: ""
17+
*/
18+
"extends": "../../api-extractor-shared.json",
19+
"mainEntryPointFilePath": "./dist/index.d.ts"
20+
}

plugins/upliftai/package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "@livekit/agents-plugin-upliftai",
3+
"version": "1.0.4",
4+
"description": "UpliftAI TTS plugin for LiveKit Node Agents",
5+
"main": "dist/index.js",
6+
"require": "dist/index.cjs",
7+
"types": "dist/index.d.ts",
8+
"exports": {
9+
"import": {
10+
"types": "./dist/index.d.ts",
11+
"default": "./dist/index.js"
12+
},
13+
"require": {
14+
"types": "./dist/index.d.cts",
15+
"default": "./dist/index.cjs"
16+
}
17+
},
18+
"author": "LiveKit",
19+
"type": "module",
20+
"repository": "[email protected]:livekit/agents-js.git",
21+
"license": "Apache-2.0",
22+
"files": [
23+
"dist",
24+
"src",
25+
"README.md"
26+
],
27+
"scripts": {
28+
"build": "tsup --onSuccess \"pnpm build:types\"",
29+
"build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
30+
"clean": "rm -rf dist",
31+
"clean:build": "pnpm clean && pnpm build",
32+
"lint": "eslint -f unix \"src/**/*.{ts,js}\"",
33+
"api:check": "api-extractor run --typescript-compiler-folder ../../node_modules/typescript",
34+
"api:update": "api-extractor run --local --typescript-compiler-folder ../../node_modules/typescript --verbose"
35+
},
36+
"devDependencies": {
37+
"@livekit/agents": "workspace:*",
38+
"@livekit/rtc-node": "^0.13.12",
39+
"@microsoft/api-extractor": "^7.35.0",
40+
"@types/node": "^20.0.0",
41+
"tsup": "^8.3.5",
42+
"typescript": "^5.0.0"
43+
},
44+
"dependencies": {
45+
"socket.io-client": "^4.7.2"
46+
},
47+
"peerDependencies": {
48+
"@livekit/agents": "workspace:*",
49+
"@livekit/rtc-node": "^0.13.12"
50+
}
51+
}

plugins/upliftai/src/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
import { Plugin } from '@livekit/agents';
5+
6+
export * from './tts.js';
7+
8+
class UpliftAIPlugin extends Plugin {
9+
constructor() {
10+
super({
11+
title: 'upliftai',
12+
version: '0.1.0',
13+
package: '@livekit/agents-plugin-upliftai',
14+
});
15+
}
16+
}
17+
18+
Plugin.registerPlugin(new UpliftAIPlugin());

0 commit comments

Comments
 (0)