from livekit.plugins import cartesia# using cartesia STT and TTS in a LiveKit agentsession = AgentSession( stt=cartesia.STT( api_key=os.environ.get("CARTESIA_API_KEY"), ), tts=cartesia.TTS( api_key=os.environ.get("CARTESIA_API_KEY"), ),)
# clone and setup livekit/agentsgit clone git@github.com:livekit/agents.gitcd agentsuv sync# run with required API keys:# - CARTESIA_API_KEY# - LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET# - some LLM provider's API keyuv run examples/other/cartesia.py console
npm i @livekit/agents @livekit/agents-plugin-cartesia
次に、エージェント作成時に Cartesia の STT と TTS プラグインを利用します。
import * as cartesia from "@livekit/agents-plugin-cartesia";// using cartesia STT and TTS in a LiveKit agentconst session = new voice.AgentSession({ stt: new cartesia.STT({ apiKey: process.env.CARTESIA_API_KEY, }), tts: new cartesia.TTS({ apiKey: process.env.CARTESIA_API_KEY, }),});
# clone and setup livekit/agents-jsgit clone git@github.com:livekit/agents-js.gitcd agents-jspnpm i && pnpm run build# run with required API keys:# - CARTESIA_API_KEY# - LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET# - some LLM provider's API keynode ./examples/src/cartesia.ts dev# go to https://agents-playground.livekit.io/# find your agent (make sure you're in the right org)# then connect to it with WebRTC transport