Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,6 @@ docs
# vscode workspace config
agents-js.code-workspace

examples/src/test_*.ts
examples/src/test_*.ts

.claude
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line

1 change: 1 addition & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@livekit/agents-plugin-cartesia": "workspace:*",
"@livekit/agents-plugin-neuphonic": "workspace:*",
"@livekit/noise-cancellation-node": "^0.1.9",
"@livekit/agents-plugin-upliftai": "workspace:^",
"@livekit/rtc-node": "^0.13.11",
"livekit-server-sdk": "^2.13.3",
"zod": "^3.23.8"
Expand Down
67 changes: 67 additions & 0 deletions examples/src/upliftai_agent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// SPDX-FileCopyrightText: 2025 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import {
type JobContext,
type JobProcess,
WorkerOptions,
cli,
defineAgent,
metrics,
voice,
} from '@livekit/agents';
import * as livekit from '@livekit/agents-plugin-livekit';
import * as openai from '@livekit/agents-plugin-openai';
import * as silero from '@livekit/agents-plugin-silero';
import * as upliftai from '@livekit/agents-plugin-upliftai';
import { BackgroundVoiceCancellation } from '@livekit/noise-cancellation-node';
import { fileURLToPath } from 'node:url';

export default defineAgent({
prewarm: async (proc: JobProcess) => {
proc.userData.vad = await silero.VAD.load();
},
entry: async (ctx: JobContext) => {
const vad = ctx.proc.userData.vad! as silero.VAD;

const agent = new voice.Agent({
vad, // openai stt needs this
instructions:
'You are a helpful voice assistant that shares some jokes. Always respond in Urdu Nastaliq script. Normalize responses for narration.',
});

const session = new voice.AgentSession({
vad, // VAD is required here for OpenAI STT
stt: new openai.STT({
model: 'gpt-4o-transcribe',
language: 'ur',
}),
tts: new upliftai.TTS(),
llm: new openai.LLM({
model: 'gpt-4o-mini',
}),
turnDetection: new livekit.turnDetector.MultilingualModel(),
});

const usageCollector = new metrics.UsageCollector();

session.on(voice.AgentSessionEventTypes.MetricsCollected, (ev) => {
metrics.logMetrics(ev.metrics);
usageCollector.collect(ev.metrics);
});

await session.start({
agent,
room: ctx.room,
inputOptions: {
noiseCancellation: BackgroundVoiceCancellation(),
},
});

session.generateReply({
instructions: 'Greet the user',
});
},
});

cli.runApp(new WorkerOptions({ agent: fileURLToPath(import.meta.url) }));
38 changes: 38 additions & 0 deletions plugins/upliftai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!--
SPDX-FileCopyrightText: 2025 LiveKit, Inc.

SPDX-License-Identifier: Apache-2.0
-->

# @livekit/agents-plugin-upliftai

UpliftAI TTS plugin for LiveKit Node Agents.

## Installation

```bash
npm install @livekit/agents-plugin-upliftai
```

## Usage

```typescript
import { TTS } from '@livekit/agents-plugin-upliftai';

// Initialize TTS with your API key
const tts = new TTS({
apiKey: 'your-api-key', // or set UPLIFTAI_API_KEY environment variable
voiceId: 'v_meklc281', // optional, defaults to v_meklc281
});


## Configuration

### Environment Variables

- `UPLIFTAI_API_KEY`: Your UpliftAI API key
- `UPLIFTAI_BASE_URL`: Base URL for the UpliftAI API (defaults to `wss://api.upliftai.org`)

## License

Apache-2.0
20 changes: 20 additions & 0 deletions plugins/upliftai/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Config file for API Extractor. For more info, please visit: https://api-extractor.com
*/
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",

/**
* Optionally specifies another JSON config file that this file extends from. This provides a way for
* standard settings to be shared across multiple projects.
*
* If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains
* the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be
* resolved using NodeJS require().
*
* SUPPORTED TOKENS: none
* DEFAULT VALUE: ""
*/
"extends": "../../api-extractor-shared.json",
"mainEntryPointFilePath": "./dist/index.d.ts"
}
51 changes: 51 additions & 0 deletions plugins/upliftai/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@livekit/agents-plugin-upliftai",
"version": "1.0.4",
"description": "UpliftAI TTS plugin for LiveKit Node Agents",
"main": "dist/index.js",
"require": "dist/index.cjs",
"types": "dist/index.d.ts",
"exports": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"author": "LiveKit",
"type": "module",
"repository": "[email protected]:livekit/agents-js.git",
"license": "Apache-2.0",
"files": [
"dist",
"src",
"README.md"
],
"scripts": {
"build": "tsup --onSuccess \"pnpm build:types\"",
"build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
"clean": "rm -rf dist",
"clean:build": "pnpm clean && pnpm build",
"lint": "eslint -f unix \"src/**/*.{ts,js}\"",
"api:check": "api-extractor run --typescript-compiler-folder ../../node_modules/typescript",
"api:update": "api-extractor run --local --typescript-compiler-folder ../../node_modules/typescript --verbose"
},
"devDependencies": {
"@livekit/agents": "workspace:*",
"@livekit/rtc-node": "^0.13.12",
"@microsoft/api-extractor": "^7.35.0",
"@types/node": "^20.0.0",
"tsup": "^8.3.5",
"typescript": "^5.0.0"
},
"dependencies": {
"socket.io-client": "^4.7.2"
},
"peerDependencies": {
"@livekit/agents": "workspace:*",
"@livekit/rtc-node": "^0.13.12"
}
}
18 changes: 18 additions & 0 deletions plugins/upliftai/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-FileCopyrightText: 2025 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { Plugin } from '@livekit/agents';

export * from './tts.js';

class UpliftAIPlugin extends Plugin {
constructor() {
super({
title: 'upliftai',
version: '0.1.0',
package: '@livekit/agents-plugin-upliftai',
});
}
}

Plugin.registerPlugin(new UpliftAIPlugin());
Loading