-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
477 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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,6 @@ | ||
--- | ||
"@livekit/agents": patch | ||
"@livekit/agents-plugin-elevenlabs": minor | ||
--- | ||
|
||
re-add ElevenLabs TTS plugin |
This file contains 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 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 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 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 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 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 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,47 @@ | ||
// SPDX-FileCopyrightText: 2024 LiveKit, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { type JobContext, WorkerOptions, cli, defineAgent } from '@livekit/agents'; | ||
import { TTS } from '@livekit/agents-plugin-elevenlabs'; | ||
import { | ||
AudioSource, | ||
LocalAudioTrack, | ||
RoomEvent, | ||
TrackPublishOptions, | ||
TrackSource, | ||
} from '@livekit/rtc-node'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
export default defineAgent({ | ||
entry: async (ctx: JobContext) => { | ||
await ctx.connect(); | ||
|
||
console.log('starting TTS example agent'); | ||
|
||
const source = new AudioSource(22050, 1); | ||
const track = LocalAudioTrack.createAudioTrack('agent-mic', source); | ||
const options = new TrackPublishOptions(); | ||
options.source = TrackSource.SOURCE_MICROPHONE; | ||
|
||
await ctx.room.localParticipant?.publishTrack(track, options); | ||
const stream = new TTS().stream(); | ||
|
||
ctx.room.on(RoomEvent.LocalTrackSubscribed, async () => { | ||
console.log('speaking "Hello!"'); | ||
stream.pushText('Hello!'); | ||
stream.flush(); | ||
|
||
await new Promise<void>((resolve) => setTimeout(resolve, 2000)); | ||
|
||
console.log('speaking "Goodbye!"'); | ||
stream.pushText('Goodbye!'); | ||
stream.flush(); | ||
}); | ||
|
||
for await (const audio of stream) { | ||
await source.captureFrame(audio.frame); | ||
} | ||
}, | ||
}); | ||
|
||
cli.runApp(new WorkerOptions({ agent: fileURLToPath(import.meta.url) })); |
This file contains 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 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,27 @@ | ||
{ | ||
"name": "@livekit/agents-plugin-elevenlabs", | ||
"version": "0.1.0", | ||
"description": "ElevenLabs plugin for LiveKit Node Agents", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"author": "LiveKit", | ||
"type": "module", | ||
"scripts": { | ||
"build": "tsc", | ||
"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": { | ||
"@microsoft/api-extractor": "^7.35.0", | ||
"@types/ws": "^8.5.10", | ||
"typescript": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"@livekit/agents": "workspace:*", | ||
"@livekit/rtc-node": "^0.10.2", | ||
"ws": "^8.16.0" | ||
} | ||
} |
This file contains 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,5 @@ | ||
// SPDX-FileCopyrightText: 2024 LiveKit, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export * from './tts.js'; |
This file contains 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 @@ | ||
// SPDX-FileCopyrightText: 2024 LiveKit, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export type TTSModels = | ||
| 'eleven_monolingual_v1' | ||
| 'eleven_multilingual_v1' | ||
| 'eleven_multilingual_v2' | ||
| 'eleven_turbo_v2' | ||
| 'eleven_turbo_v2_5'; | ||
|
||
export type TTSEncoding = | ||
// XXX(nbsp): MP3 is not yet supported | ||
// | 'mp3_22050_32' | ||
// | 'mp3_44100_32' | ||
// | 'mp3_44100_64' | ||
// | 'mp3_44100_96' | ||
// | 'mp3_44100_128' | ||
// | 'mp3_44100_192' | ||
'pcm_16000' | 'pcm_22050' | 'pcm_44100'; |
Oops, something went wrong.