Skip to content

Commit

Permalink
plugins(cartesia): init with TTS (#217)
Browse files Browse the repository at this point in the history
Co-authored-by: Théo Monnom <[email protected]>
  • Loading branch information
nbsp and theomonnom authored Jan 6, 2025
1 parent ba39f03 commit 9f31ba0
Show file tree
Hide file tree
Showing 26 changed files with 492 additions and 67 deletions.
5 changes: 0 additions & 5 deletions .changeset/brave-needles-boil.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/calm-ants-build.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/clean-lies-grow.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/eight-mugs-glow.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/few-games-destroy.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/few-schools-run.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/hot-otters-pay.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/khaki-ties-design.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/moody-poems-juggle.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/nine-planes-ring.md

This file was deleted.

9 changes: 0 additions & 9 deletions .changeset/proud-monkeys-bow.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/sweet-papayas-complain.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/tiny-cameras-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@livekit/agents-plugin-cartesia": minor
---

plugins(cartesia): init with TTS
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,19 @@ jobs:
run: pnpm test agents
- name: Test all plugins
if: steps.filter.outputs.agents-or-tests == 'true' || github.event_name != 'pull_request'
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ELEVEN_API_KEY: ${{ secrets.ELEVEN_API_KEY }}
DEEPGRAM_API_KEY: ${{ secrets.DEEPGRAM_API_KEY }}
CARTESIA_API_KEY: ${{ secrets.CARTESIA_API_KEY }}
run: pnpm test plugins
- name: Test specific plugins
if: steps.check.outputs.agents-or-tests == 'false' && steps.check.outputs.plugins == 'true' && github.event_name == 'pull_request'
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ELEVEN_API_KEY: ${{ secrets.ELEVEN_API_KEY }}
DEEPGRAM_API_KEY: ${{ secrets.DEEPGRAM_API_KEY }}
CARTESIA_API_KEY: ${{ secrets.CARTESIA_API_KEY }}
run: |
plugins=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^plugins.*\.ts$' | cut -d/ -f2 | sort -u | tr '\n' ' ')
read -ra plugins <<< "$plugins"
Expand Down
17 changes: 17 additions & 0 deletions plugins/cartesia/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--
SPDX-FileCopyrightText: 2024 LiveKit, Inc.
SPDX-License-Identifier: Apache-2.0
-->
# Cartesia plugin for LiveKit Agents

The Agents Framework is designed for building realtime, programmable
participants that run on servers. Use it to create conversational, multi-modal
voice agents that can see, hear, and understand.

This package contains the Cartesia plugin, which allows for voice synthesis.
Refer to the [documentation](https://docs.livekit.io/agents/overview/) for
information on how to use it, or browse the [API
reference](https://docs.livekit.io/agents-js/modules/plugins_agents_plugin_cartesia.html).
See the [repository](https://github.com/livekit/agents-js) for more information
about the framework as a whole.
20 changes: 20 additions & 0 deletions plugins/cartesia/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"
}
49 changes: 49 additions & 0 deletions plugins/cartesia/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "@livekit/agents-plugin-cartesia",
"version": "0.0.0",
"description": "Cartesia plugin for LiveKit Node Agents",
"main": "dist/index.js",
"require": "dist/index.cjs",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./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 \"tsc --declaration --emitDeclarationOnly\"",
"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:^x",
"@livekit/agents-plugin-openai": "workspace:^x",
"@livekit/agents-plugins-test": "workspace:^x",
"@livekit/rtc-node": "^0.12.1",
"@microsoft/api-extractor": "^7.35.0",
"@types/ws": "^8.5.10",
"tsup": "^8.3.5",
"typescript": "^5.0.0"
},
"dependencies": {
"ws": "^8.16.0"
},
"peerDependencies": {
"@livekit/agents": "workspace:^x",
"@livekit/rtc-node": "^0.12.1"
}
}
5 changes: 5 additions & 0 deletions plugins/cartesia/src/index.ts
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';
45 changes: 45 additions & 0 deletions plugins/cartesia/src/models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0

export type TTSModels = 'sonic-english' | 'sonic-multilingual';

export type TTSLanguages = 'en' | 'es' | 'fr' | 'de' | 'pt' | 'zh' | 'ja';

export const TTSDefaultVoiceId = 'c2ac25f9-ecc4-4f56-9095-651354df60c0';

export type TTSVoiceSpeed = 'fastest' | 'fast' | 'normal' | 'slow' | 'slowest';

export type TTSVoiceEmotion =
| 'anger:lowest'
| 'anger:low'
| 'anger'
| 'anger:high'
| 'anger:highest'
| 'positivity:lowest'
| 'positivity:low'
| 'positivity'
| 'positivity:high'
| 'positivity:highest'
| 'surprise:lowest'
| 'surprise:low'
| 'surprise'
| 'surprise:high'
| 'surprise:highest'
| 'sadness:lowest'
| 'sadness:low'
| 'sadness'
| 'sadness:high'
| 'sadness:highest'
| 'curiosity:lowest'
| 'curiosity:low'
| 'curiosity'
| 'curiosity:high'
| 'curiosity:highest';

export type TTSEncoding =
// XXX(nbsp): not yet supported
// | 'pcm_f32le'
// | 'pcm_mulaw'
// | 'pcm_alaw'
'pcm_s16le';
11 changes: 11 additions & 0 deletions plugins/cartesia/src/tts.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
//
// SPDX-License-Identifier: Apache-2.0
import { STT } from '@livekit/agents-plugin-openai';
import { tts } from '@livekit/agents-plugins-test';
import { describe } from 'vitest';
import { TTS } from './tts.js';

describe('Cartesia', async () => {
await tts(new TTS(), new STT());
});
Loading

0 comments on commit 9f31ba0

Please sign in to comment.