-
Notifications
You must be signed in to change notification settings - Fork 166
Uplift AI TTS #712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zaidqureshi2
wants to merge
2
commits into
livekit:main
Choose a base branch
from
zaidqureshi2:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Uplift AI TTS #712
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,4 +189,6 @@ docs | |
| # vscode workspace config | ||
| agents-js.code-workspace | ||
|
|
||
| examples/src/test_*.ts | ||
| examples/src/test_*.ts | ||
|
|
||
| .claude | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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()); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line