From 039a8f6c7ddf0bbf654ee12dc6260c44d5a319fa Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Wed, 4 Mar 2026 22:55:51 -0500 Subject: [PATCH] Update examples --- .../foundational/01-say-one-thing-piper.py | 4 +- .../foundational/01-say-one-thing-rime.py | 6 +- examples/foundational/01-say-one-thing.py | 6 +- examples/foundational/01a-local-audio.py | 6 +- examples/foundational/01b-livekit-audio.py | 6 +- examples/foundational/02-llm-say-one-thing.py | 6 +- .../04-transports-small-webrtc.py | 6 +- examples/foundational/04a-transports-daily.py | 12 ++-- .../foundational/04b-transports-livekit.py | 6 +- .../foundational/05-sync-speech-and-image.py | 6 +- .../05a-local-sync-speech-and-image.py | 6 +- .../foundational/06-listen-and-respond.py | 6 +- examples/foundational/06a-image-sync.py | 6 +- .../07-interruptible-cartesia-http.py | 6 +- .../07a-interruptible-speechmatics-vad.py | 37 +++++------- .../07a-interruptible-speechmatics.py | 36 +++++------- .../07b-interruptible-langchain.py | 6 +- .../07c-interruptible-deepgram-flux.py | 15 +++-- .../07c-interruptible-deepgram-http.py | 10 ++-- .../07c-interruptible-deepgram-vad.py | 17 ++++-- .../07c-interruptible-deepgram.py | 9 ++- .../07d-interruptible-elevenlabs-http.py | 6 +- .../07d-interruptible-elevenlabs.py | 6 +- .../foundational/07g-interruptible-openai.py | 23 ++++---- .../07h-interruptible-openpipe.py | 6 +- .../foundational/07i-interruptible-xtts.py | 6 +- .../07j-interruptible-gladia-vad.py | 28 +++++---- .../foundational/07j-interruptible-gladia.py | 28 +++++---- .../foundational/07k-interruptible-lmnt.py | 9 ++- .../foundational/07l-interruptible-groq.py | 6 +- .../07m-interruptible-aws-strands.py | 9 ++- .../foundational/07m-interruptible-aws.py | 9 ++- .../07n-interruptible-gemini-image.py | 22 ++++--- .../foundational/07n-interruptible-gemini.py | 14 +++-- .../07n-interruptible-google-http.py | 27 +++++---- .../foundational/07n-interruptible-google.py | 27 +++++---- ...interruptible-assemblyai-turn-detection.py | 11 ++-- .../07o-interruptible-assemblyai.py | 6 +- .../07p-interruptible-krisp-viva.py | 7 ++- .../foundational/07p-interruptible-krisp.py | 9 ++- .../07q-interruptible-rime-http.py | 7 ++- .../foundational/07q-interruptible-rime.py | 6 +- .../foundational/07r-interruptible-nvidia.py | 6 +- .../07s-interruptible-google-audio-in.py | 13 +++-- .../foundational/07t-interruptible-fish.py | 6 +- .../07v-interruptible-neuphonic-http.py | 6 +- .../07v-interruptible-neuphonic.py | 6 +- .../foundational/07w-interruptible-fal.py | 6 +- .../foundational/07x-interruptible-local.py | 6 +- .../foundational/07y-interruptible-minimax.py | 6 +- .../07z-interruptible-sarvam-http.py | 6 +- .../foundational/07z-interruptible-sarvam.py | 14 +++-- .../foundational/07za-interruptible-soniox.py | 20 ++++--- .../07zb-interruptible-inworld-http.py | 10 ++-- .../07zb-interruptible-inworld.py | 10 ++-- .../07zc-interruptible-asyncai-http.py | 6 +- .../07zc-interruptible-asyncai.py | 6 +- .../07zd-interruptible-aicoustics.py | 6 +- .../foundational/07ze-interruptible-hume.py | 6 +- .../07zf-interruptible-gradium.py | 10 ++-- .../foundational/07zg-interruptible-camb.py | 6 +- .../foundational/07zi-interruptible-piper.py | 8 ++- .../foundational/07zj-interruptible-kokoro.py | 8 ++- .../07zk-interruptible-resemble.py | 6 +- .../foundational/08-custom-frame-processor.py | 6 +- examples/foundational/10-wake-phrase.py | 6 +- examples/foundational/11-sound-effects.py | 6 +- .../foundational/12-describe-image-openai.py | 6 +- .../12a-describe-image-anthropic.py | 6 +- .../foundational/12b-describe-image-aws.py | 20 ++++--- .../12c-describe-image-gemini-flash.py | 6 +- .../12d-describe-image-moondream.py | 6 +- .../13b-deepgram-transcription.py | 6 +- .../foundational/13c-gladia-transcription.py | 6 +- .../foundational/13c-gladia-translation.py | 12 ++-- .../13d-assemblyai-transcription.py | 7 +-- examples/foundational/13e-whisper-mlx.py | 8 ++- .../13g-sambanova-transcription.py | 6 +- .../13h-speechmatics-transcription.py | 4 +- .../foundational/13l-gradium-transcription.py | 7 ++- .../foundational/13m-openai-transcription.py | 8 ++- examples/foundational/14-function-calling.py | 6 +- .../14a-function-calling-anthropic.py | 22 +++---- .../14c-function-calling-together.py | 12 ++-- .../14d-function-calling-anthropic-video.py | 6 +- .../14d-function-calling-aws-video.py | 20 ++++--- ...14d-function-calling-gemini-flash-video.py | 6 +- .../14d-function-calling-moondream-video.py | 6 +- .../14d-function-calling-openai-video.py | 6 +- .../14e-function-calling-google.py | 58 ++++++++++--------- .../foundational/14f-function-calling-groq.py | 6 +- .../foundational/14g-function-calling-grok.py | 6 +- .../14h-function-calling-azure.py | 12 ++-- .../14i-function-calling-fireworks.py | 12 ++-- .../14j-function-calling-nvidia.py | 29 ++++------ .../14k-function-calling-cerebras.py | 6 +- .../14l-function-calling-deepseek.py | 12 ++-- .../14m-function-calling-openrouter.py | 16 +++-- .../14n-function-calling-perplexity.py | 20 +++---- ...o-function-calling-gemini-openai-format.py | 11 +++- .../14p-function-calling-gemini-vertex-ai.py | 7 ++- .../foundational/14q-function-calling-qwen.py | 6 +- .../foundational/14r-function-calling-aws.py | 17 ++++-- .../14s-function-calling-sambanova.py | 6 +- .../14t-function-calling-direct.py | 6 +- .../14u-function-calling-ollama.py | 12 ++-- .../14v-function-calling-openai.py | 16 ++--- .../14w-function-calling-mistral.py | 6 +- .../14x-function-calling-openpipe.py | 6 +- examples/foundational/15-switch-voices.py | 14 +++-- examples/foundational/15a-switch-languages.py | 10 +++- .../16-gpu-container-local-bot.py | 12 ++-- examples/foundational/17-detect-user-idle.py | 6 +- .../19b-openai-realtime-beta-text.py | 6 +- .../foundational/19b-openai-realtime-text.py | 6 +- .../20a-persistent-context-openai.py | 6 +- .../20c-persistent-context-anthropic.py | 10 ++-- .../20d-persistent-context-gemini.py | 6 +- examples/foundational/21-tavus-transport.py | 6 +- .../foundational/21a-tavus-video-service.py | 6 +- .../22-filter-incomplete-turns.py | 24 ++++---- .../foundational/23-bot-background-sound.py | 6 +- .../foundational/24-user-mute-strategy.py | 9 ++- examples/foundational/25-google-audio-in.py | 18 +++--- examples/foundational/26d-gemini-live-text.py | 2 +- examples/foundational/27-simli-layer.py | 12 ++-- .../foundational/28-user-assistant-turns.py | 6 +- .../foundational/29-turn-tracking-observer.py | 6 +- examples/foundational/30-observer.py | 6 +- .../32-gemini-grounding-metadata.py | 6 +- examples/foundational/33-gemini-rag.py | 29 ++++++---- examples/foundational/34-audio-recording.py | 7 ++- .../35-pattern-pair-voice-switching.py | 23 ++++---- .../foundational/36-user-email-gathering.py | 6 +- examples/foundational/37-mem0.py | 12 ++-- examples/foundational/38-smart-turn-fal.py | 6 +- .../38a-smart-turn-local-coreml.py | 6 +- examples/foundational/38b-smart-turn-local.py | 6 +- examples/foundational/39-mcp-stdio.py | 40 ++++++------- .../foundational/39a-mcp-streamable-http.py | 6 +- .../39b-mcp-streamable-http-gemini-live.py | 6 +- examples/foundational/39c-multiple-mcp.py | 14 ++--- .../foundational/42-interruption-config.py | 6 +- examples/foundational/43-heygen-transport.py | 6 +- .../foundational/43a-heygen-video-service.py | 6 +- .../foundational/44-voicemail-detection.py | 6 +- .../45-before-and-after-events.py | 6 +- examples/foundational/47-sentry-metrics.py | 6 +- examples/foundational/48-service-switcher.py | 31 +++++----- .../foundational/49a-thinking-anthropic.py | 19 ++++-- examples/foundational/49b-thinking-google.py | 15 ++--- .../49c-thinking-functions-anthropic.py | 19 ++++-- .../49d-thinking-functions-google.py | 15 ++--- examples/foundational/52-live-translation.py | 6 +- .../53-concurrent-llm-evaluation.py | 43 ++++++-------- .../53-concurrent-llm-rtvi-ignored-sources.py | 43 +++++--------- .../54-context-summarization-openai.py | 6 +- .../54a-context-summarization-google.py | 6 +- ...54b-context-summarization-manual-openai.py | 36 +++++------- ...54c-context-summarization-dedicated-llm.py | 42 +++++++------- .../55a-update-settings-deepgram-flux-stt.py | 6 +- ...-update-settings-deepgram-sagemaker-stt.py | 6 +- .../55a-update-settings-deepgram-stt.py | 6 +- .../55b-update-settings-azure-stt.py | 6 +- .../55c-update-settings-google-stt.py | 6 +- .../55d-update-settings-assemblyai-stt.py | 6 +- .../55e-update-settings-gladia-stt.py | 6 +- ...update-settings-elevenlabs-realtime-stt.py | 6 +- .../55g-update-settings-elevenlabs-stt.py | 6 +- .../55h-update-settings-speechmatics-stt.py | 6 +- .../55i-update-settings-whisper-api-stt.py | 6 +- .../55j-update-settings-sarvam-stt.py | 6 +- .../55k-update-settings-soniox-stt.py | 6 +- .../55l-update-settings-aws-transcribe-stt.py | 6 +- .../55m-update-settings-cartesia-stt.py | 6 +- .../55n-update-settings-cartesia-http-tts.py | 4 +- .../55n-update-settings-cartesia-tts.py | 4 +- .../55zi-update-settings-azure-llm.py | 6 +- .../55zi-update-settings-openai-llm.py | 6 +- .../55zj-update-settings-anthropic-llm.py | 6 +- .../55zk-update-settings-google-llm.py | 6 +- .../55zk-update-settings-google-vertex-llm.py | 6 +- .../55zp-update-settings-aws-bedrock-llm.py | 6 +- .../55zq-update-settings-fal-stt.py | 6 +- .../55zr-update-settings-gradium-stt.py | 6 +- ...zt-update-settings-nvidia-segmented-stt.py | 6 +- .../55zt-update-settings-nvidia-stt.py | 6 +- ...5zu-update-settings-openai-realtime-stt.py | 6 +- .../55zx-update-settings-cerebras-llm.py | 6 +- .../55zy-update-settings-deepseek-llm.py | 6 +- .../55zz-update-settings-fireworks-llm.py | 6 +- .../55zza-update-settings-grok-llm.py | 6 +- .../55zzb-update-settings-groq-llm.py | 6 +- .../55zzc-update-settings-mistral-llm.py | 6 +- .../55zzd-update-settings-nvidia-llm.py | 6 +- .../55zze-update-settings-ollama-llm.py | 6 +- .../55zzf-update-settings-openrouter-llm.py | 6 +- .../55zzg-update-settings-perplexity-llm.py | 6 +- .../55zzh-update-settings-qwen-llm.py | 6 +- .../55zzi-update-settings-sambanova-llm.py | 6 +- .../55zzj-update-settings-together-llm.py | 6 +- .../55zzn-update-settings-groq-stt.py | 6 +- .../foundational/56-lemonslice-transport.py | 6 +- examples/quickstart/bot.py | 6 +- scripts/evals/eval.py | 2 +- src/pipecat/services/openai/base_llm.py | 2 +- src/pipecat/services/sarvam/tts.py | 21 +------ 207 files changed, 1241 insertions(+), 852 deletions(-) diff --git a/examples/foundational/01-say-one-thing-piper.py b/examples/foundational/01-say-one-thing-piper.py index cace8dbeb..6c4e1836e 100644 --- a/examples/foundational/01-say-one-thing-piper.py +++ b/examples/foundational/01-say-one-thing-piper.py @@ -39,7 +39,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create an HTTP session async with aiohttp.ClientSession() as session: tts = PiperHttpTTSService( - base_url=os.getenv("PIPER_BASE_URL"), aiohttp_session=session, sample_rate=24000 + base_url=os.getenv("PIPER_BASE_URL"), + aiohttp_session=session, + sample_rate=24000, ) task = PipelineTask( diff --git a/examples/foundational/01-say-one-thing-rime.py b/examples/foundational/01-say-one-thing-rime.py index 2a31efa68..63667fac8 100644 --- a/examples/foundational/01-say-one-thing-rime.py +++ b/examples/foundational/01-say-one-thing-rime.py @@ -16,7 +16,7 @@ from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.rime.tts import RimeHttpTTSService +from pipecat.services.rime.tts import RimeHttpTTSService, RimeTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -39,8 +39,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async with aiohttp.ClientSession() as session: tts = RimeHttpTTSService( api_key=os.getenv("RIME_API_KEY", ""), - voice_id="rex", aiohttp_session=session, + settings=RimeTTSSettings( + voice="rex", + ), ) task = PipelineTask( diff --git a/examples/foundational/01-say-one-thing.py b/examples/foundational/01-say-one-thing.py index 7df26701c..bfcf829cc 100644 --- a/examples/foundational/01-say-one-thing.py +++ b/examples/foundational/01-say-one-thing.py @@ -15,7 +15,7 @@ from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -37,7 +37,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) task = PipelineTask( diff --git a/examples/foundational/01a-local-audio.py b/examples/foundational/01a-local-audio.py index 432880203..77565dffe 100644 --- a/examples/foundational/01a-local-audio.py +++ b/examples/foundational/01a-local-audio.py @@ -15,7 +15,7 @@ from pipecat.frames.frames import EndFrame, TTSSpeakFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.transports.local.audio import LocalAudioTransport, LocalAudioTransportParams load_dotenv(override=True) @@ -29,7 +29,9 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) pipeline = Pipeline([tts, transport.output()]) diff --git a/examples/foundational/01b-livekit-audio.py b/examples/foundational/01b-livekit-audio.py index a7697646e..ad4c785eb 100644 --- a/examples/foundational/01b-livekit-audio.py +++ b/examples/foundational/01b-livekit-audio.py @@ -16,7 +16,7 @@ from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineTask from pipecat.runner.livekit import configure -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.transports.livekit.transport import LiveKitParams, LiveKitTransport load_dotenv(override=True) @@ -37,7 +37,9 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) runner = PipelineRunner() diff --git a/examples/foundational/02-llm-say-one-thing.py b/examples/foundational/02-llm-say-one-thing.py index 9cfd7c39e..3ee536a64 100644 --- a/examples/foundational/02-llm-say-one-thing.py +++ b/examples/foundational/02-llm-say-one-thing.py @@ -16,7 +16,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -39,7 +39,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/04-transports-small-webrtc.py b/examples/foundational/04-transports-small-webrtc.py index d29171dd2..6cf32a285 100644 --- a/examples/foundational/04-transports-small-webrtc.py +++ b/examples/foundational/04-transports-small-webrtc.py @@ -27,7 +27,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMContextAggregatorPair, LLMUserAggregatorParams, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import TransportParams @@ -67,7 +67,9 @@ async def run_example(webrtc_connection: SmallWebRTCConnection): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/04a-transports-daily.py b/examples/foundational/04a-transports-daily.py index b0a7958ef..8b23cb69e 100644 --- a/examples/foundational/04a-transports-daily.py +++ b/examples/foundational/04a-transports-daily.py @@ -23,8 +23,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMUserAggregatorParams, ) from pipecat.runner.daily import configure -from pipecat.services.cartesia.tts import CartesiaTTSService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.daily.transport import DailyParams, DailyTransport load_dotenv(override=True) @@ -50,12 +50,16 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o", + settings=OpenAILLMSettings( + model="gpt-4o", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/04b-transports-livekit.py b/examples/foundational/04b-transports-livekit.py index e05c5ddc3..f55f106c1 100644 --- a/examples/foundational/04b-transports-livekit.py +++ b/examples/foundational/04b-transports-livekit.py @@ -29,7 +29,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMUserAggregatorParams, ) from pipecat.runner.livekit import configure -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.livekit.transport import LiveKitParams, LiveKitTransport @@ -62,7 +62,9 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) context = LLMContext() diff --git a/examples/foundational/05-sync-speech-and-image.py b/examples/foundational/05-sync-speech-and-image.py index c1b142670..95de1143b 100644 --- a/examples/foundational/05-sync-speech-and-image.py +++ b/examples/foundational/05-sync-speech-and-image.py @@ -27,7 +27,7 @@ from pipecat.processors.aggregators.sentence import SentenceAggregator from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaHttpTTSService +from pipecat.services.cartesia.tts import CartesiaHttpTTSService, CartesiaTTSSettings from pipecat.services.fal.image import FalImageGenService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -98,7 +98,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaHttpTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) imagegen = FalImageGenService( diff --git a/examples/foundational/05a-local-sync-speech-and-image.py b/examples/foundational/05a-local-sync-speech-and-image.py index 56309c0a5..03b690c11 100644 --- a/examples/foundational/05a-local-sync-speech-and-image.py +++ b/examples/foundational/05a-local-sync-speech-and-image.py @@ -28,7 +28,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.sentence import SentenceAggregator from pipecat.processors.frame_processor import FrameDirection, FrameProcessor -from pipecat.services.cartesia.tts import CartesiaHttpTTSService +from pipecat.services.cartesia.tts import CartesiaHttpTTSService, CartesiaTTSSettings from pipecat.services.fal.image import FalImageGenService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.local.tk import TkLocalTransport, TkTransportParams @@ -98,7 +98,9 @@ async def main(): tts = CartesiaHttpTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) imagegen = FalImageGenService( diff --git a/examples/foundational/06-listen-and-respond.py b/examples/foundational/06-listen-and-respond.py index 418b3b5af..c90d79c4e 100644 --- a/examples/foundational/06-listen-and-respond.py +++ b/examples/foundational/06-listen-and-respond.py @@ -28,7 +28,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -83,7 +83,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/06a-image-sync.py b/examples/foundational/06a-image-sync.py index f963aa339..666f4739c 100644 --- a/examples/foundational/06a-image-sync.py +++ b/examples/foundational/06a-image-sync.py @@ -29,7 +29,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -100,7 +100,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07-interruptible-cartesia-http.py b/examples/foundational/07-interruptible-cartesia-http.py index 558217413..b92454c50 100644 --- a/examples/foundational/07-interruptible-cartesia-http.py +++ b/examples/foundational/07-interruptible-cartesia-http.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.stt import CartesiaSTTService -from pipecat.services.cartesia.tts import CartesiaHttpTTSService +from pipecat.services.cartesia.tts import CartesiaHttpTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaHttpTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07a-interruptible-speechmatics-vad.py b/examples/foundational/07a-interruptible-speechmatics-vad.py index d75ae2b1f..5bb8459e2 100644 --- a/examples/foundational/07a-interruptible-speechmatics-vad.py +++ b/examples/foundational/07a-interruptible-speechmatics-vad.py @@ -21,10 +21,10 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.openai.base_llm import BaseOpenAILLMService +from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.speechmatics.stt import SpeechmaticsSTTService -from pipecat.services.speechmatics.tts import SpeechmaticsTTSService +from pipecat.services.speechmatics.stt import SpeechmaticsSTTService, SpeechmaticsSTTSettings +from pipecat.services.speechmatics.tts import SpeechmaticsTTSService, SpeechmaticsTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -93,7 +93,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async with aiohttp.ClientSession() as session: stt = SpeechmaticsSTTService( api_key=os.getenv("SPEECHMATICS_API_KEY"), - params=SpeechmaticsSTTService.InputParams( + settings=SpeechmaticsSTTSettings( language=Language.EN, turn_detection_mode=SpeechmaticsSTTService.TurnDetectionMode.ADAPTIVE, # focus_speakers=["S1"], @@ -104,32 +104,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = SpeechmaticsTTSService( api_key=os.getenv("SPEECHMATICS_API_KEY"), - voice_id="sarah", + settings=SpeechmaticsTTSSettings( + voice="sarah", + ), aiohttp_session=session, ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - params=BaseOpenAILLMService.InputParams(temperature=0.75), + settings=OpenAILLMSettings( + temperature=0.75, + ), + system_instruction="You are a helpful British assistant called Sarah. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Always include punctuation in your responses. Give very short replies - do not give longer replies unless strictly necessary. Respond to what the user said in a concise, funny, creative and helpful way. Use `` tags to identify different speakers - do not use tags in your replies. Do not respond to speakers within `` tags unless explicitly asked to.", ) - messages = [ - { - "role": "system", - "content": ( - "You are a helpful British assistant called Sarah. " - "Your goal is to demonstrate your capabilities in a succinct way. " - "Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. " - "Always include punctuation in your responses. " - "Give very short replies - do not give longer replies unless strictly necessary. " - "Respond to what the user said in a concise, funny, creative and helpful way. " - "Use `` tags to identify different speakers - do not use tags in your replies. " - "Do not respond to speakers within `` tags unless explicitly asked to. " - ), - }, - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(user_turn_strategies=ExternalUserTurnStrategies()), @@ -160,7 +149,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Say a short hello to the user."}) + context.add_message({"role": "system", "content": "Say a short hello to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/07a-interruptible-speechmatics.py b/examples/foundational/07a-interruptible-speechmatics.py index f8b4cdf19..caecb74be 100644 --- a/examples/foundational/07a-interruptible-speechmatics.py +++ b/examples/foundational/07a-interruptible-speechmatics.py @@ -22,10 +22,10 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.openai.base_llm import BaseOpenAILLMService +from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.speechmatics.stt import SpeechmaticsSTTService -from pipecat.services.speechmatics.tts import SpeechmaticsTTSService +from pipecat.services.speechmatics.stt import SpeechmaticsSTTService, SpeechmaticsSTTSettings +from pipecat.services.speechmatics.tts import SpeechmaticsTTSService, SpeechmaticsTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -76,7 +76,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async with aiohttp.ClientSession() as session: stt = SpeechmaticsSTTService( api_key=os.getenv("SPEECHMATICS_API_KEY"), - params=SpeechmaticsSTTService.InputParams( + settings=SpeechmaticsSTTSettings( language=Language.EN, speaker_active_format="<{speaker_id}>{text}", ), @@ -84,31 +84,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = SpeechmaticsTTSService( api_key=os.getenv("SPEECHMATICS_API_KEY"), - voice_id="sarah", + settings=SpeechmaticsTTSSettings( + voice="sarah", + ), aiohttp_session=session, ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - params=BaseOpenAILLMService.InputParams(temperature=0.75), + settings=OpenAILLMSettings( + temperature=0.75, + ), + system_instruction="You are a helpful British assistant called Sarah. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Always include punctuation in your responses. Give very short replies - do not give longer replies unless strictly necessary. Respond to what the user said in a concise, funny, creative and helpful way. Use `` tags to identify different speakers - do not use tags in your replies. Do not respond to speakers within `` tags unless explicitly asked to.", ) - messages = [ - { - "role": "system", - "content": ( - "You are a helpful British assistant called Sarah. " - "Your goal is to demonstrate your capabilities in a succinct way. " - "Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. " - "Always include punctuation in your responses. " - "Give very short replies - do not give longer replies unless strictly necessary. " - "Respond to what the user said in a concise, funny, creative and helpful way. " - "Use `` tags to identify different speakers - do not use tags in your replies." - ), - }, - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), @@ -139,7 +129,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Say a short hello to the user."}) + context.add_message({"role": "system", "content": "Say a short hello to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/07b-interruptible-langchain.py b/examples/foundational/07b-interruptible-langchain.py index 21290b576..e7a5dc1b8 100644 --- a/examples/foundational/07b-interruptible-langchain.py +++ b/examples/foundational/07b-interruptible-langchain.py @@ -28,7 +28,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frameworks.langchain import LangchainProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -71,7 +71,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) prompt = ChatPromptTemplate.from_messages( diff --git a/examples/foundational/07c-interruptible-deepgram-flux.py b/examples/foundational/07c-interruptible-deepgram-flux.py index 3f2d6e28d..4eafc24a7 100644 --- a/examples/foundational/07c-interruptible-deepgram-flux.py +++ b/examples/foundational/07c-interruptible-deepgram-flux.py @@ -22,8 +22,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.deepgram.flux.stt import DeepgramFluxSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService +from pipecat.services.deepgram.flux.stt import DeepgramFluxSTTService, DeepgramFluxSTTSettings +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -56,10 +56,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramFluxSTTService( api_key=os.getenv("DEEPGRAM_API_KEY"), - params=DeepgramFluxSTTService.InputParams(min_confidence=0.3), + settings=DeepgramFluxSTTSettings( + min_confidence=0.3, + ), ) - tts = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY"), voice="aura-2-andromeda-en") + tts = DeepgramTTSService( + api_key=os.getenv("DEEPGRAM_API_KEY"), + settings=DeepgramTTSSettings( + voice="aura-2-andromeda-en", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07c-interruptible-deepgram-http.py b/examples/foundational/07c-interruptible-deepgram-http.py index 6955ccbd1..e6281fbc5 100644 --- a/examples/foundational/07c-interruptible-deepgram-http.py +++ b/examples/foundational/07c-interruptible-deepgram-http.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramHttpTTSService +from pipecat.services.deepgram.tts import DeepgramHttpTTSService, DeepgramTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = DeepgramHttpTTSService( api_key=os.getenv("DEEPGRAM_API_KEY"), - voice="aura-2-andromeda-en", + settings=DeepgramTTSSettings( + voice="aura-2-andromeda-en", + ), aiohttp_session=session, ) @@ -68,9 +70,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) - messages = [] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/07c-interruptible-deepgram-vad.py b/examples/foundational/07c-interruptible-deepgram-vad.py index aaa81fc90..81acad665 100644 --- a/examples/foundational/07c-interruptible-deepgram-vad.py +++ b/examples/foundational/07c-interruptible-deepgram-vad.py @@ -7,7 +7,6 @@ import os -from deepgram import LiveOptions from dotenv import load_dotenv from loguru import logger @@ -22,8 +21,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService +from pipecat.services.deepgram.stt import DeepgramSTTService, DeepgramSTTSettings +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -56,10 +55,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService( api_key=os.getenv("DEEPGRAM_API_KEY"), - live_options=LiveOptions(vad_events=True, utterance_end_ms="1000"), + settings=DeepgramSTTSettings( + vad_events=True, + utterance_end_ms="1000", + ), ) - tts = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY"), voice="aura-2-andromeda-en") + tts = DeepgramTTSService( + api_key=os.getenv("DEEPGRAM_API_KEY"), + settings=DeepgramTTSSettings( + voice="aura-2-andromeda-en", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07c-interruptible-deepgram.py b/examples/foundational/07c-interruptible-deepgram.py index 1cbfc72cc..d33a19d56 100644 --- a/examples/foundational/07c-interruptible-deepgram.py +++ b/examples/foundational/07c-interruptible-deepgram.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -55,7 +55,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - tts = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY"), voice="aura-2-andromeda-en") + tts = DeepgramTTSService( + api_key=os.getenv("DEEPGRAM_API_KEY"), + settings=DeepgramTTSSettings( + voice="aura-2-andromeda-en", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07d-interruptible-elevenlabs-http.py b/examples/foundational/07d-interruptible-elevenlabs-http.py index 85cffc270..0dd95900c 100644 --- a/examples/foundational/07d-interruptible-elevenlabs-http.py +++ b/examples/foundational/07d-interruptible-elevenlabs-http.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.elevenlabs.stt import ElevenLabsSTTService -from pipecat.services.elevenlabs.tts import ElevenLabsHttpTTSService +from pipecat.services.elevenlabs.tts import ElevenLabsHttpTTSService, ElevenLabsHttpTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -63,8 +63,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ElevenLabsHttpTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), - voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), aiohttp_session=session, + settings=ElevenLabsHttpTTSSettings( + voice=os.getenv("ELEVENLABS_VOICE_ID", ""), + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07d-interruptible-elevenlabs.py b/examples/foundational/07d-interruptible-elevenlabs.py index b55345f33..c4f31ac9b 100644 --- a/examples/foundational/07d-interruptible-elevenlabs.py +++ b/examples/foundational/07d-interruptible-elevenlabs.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.elevenlabs.stt import ElevenLabsRealtimeSTTService -from pipecat.services.elevenlabs.tts import ElevenLabsTTSService +from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), - voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + settings=ElevenLabsTTSSettings( + voice=os.getenv("ELEVENLABS_VOICE_ID", ""), + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07g-interruptible-openai.py b/examples/foundational/07g-interruptible-openai.py index a29e8210f..86b6c9267 100644 --- a/examples/foundational/07g-interruptible-openai.py +++ b/examples/foundational/07g-interruptible-openai.py @@ -23,8 +23,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.openai.stt import OpenAIRealtimeSTTService -from pipecat.services.openai.tts import OpenAITTSService +from pipecat.services.openai.stt import OpenAIRealtimeSTTService, OpenAIRealtimeSTTSettings +from pipecat.services.openai.tts import OpenAITTSService, OpenAITTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -55,16 +55,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = OpenAIRealtimeSTTService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o-transcribe", - prompt="Expect words related to dogs, such as breed names.", - language=Language.EN, - # Uses local VAD by default. - # To enable server-side VAD, set turn_detection=None or - # a dict with server_vad settings. - # turn_detection={"type": "server_vad", "threshold": 0.5}, + settings=OpenAIRealtimeSTTSettings( + model="gpt-4o-transcribe", + prompt="Expect words related to dogs, such as breed names.", + language=Language.EN, + ), ) - tts = OpenAITTSService(api_key=os.getenv("OPENAI_API_KEY"), voice="ballad") + tts = OpenAITTSService( + api_key=os.getenv("OPENAI_API_KEY"), + settings=OpenAITTSSettings( + voice="ballad", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07h-interruptible-openpipe.py b/examples/foundational/07h-interruptible-openpipe.py index e3ddc05b8..6dbf04296 100644 --- a/examples/foundational/07h-interruptible-openpipe.py +++ b/examples/foundational/07h-interruptible-openpipe.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openpipe.llm import OpenPipeLLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) timestamp = int(time.time()) diff --git a/examples/foundational/07i-interruptible-xtts.py b/examples/foundational/07i-interruptible-xtts.py index 00883e37f..6837917aa 100644 --- a/examples/foundational/07i-interruptible-xtts.py +++ b/examples/foundational/07i-interruptible-xtts.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.xtts.tts import XTTSService +from pipecat.services.xtts.tts import XTTSService, XTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = XTTSService( aiohttp_session=session, - voice_id="Claribel Dervla", + settings=XTTSSettings( + voice="Claribel Dervla", + ), base_url="http://localhost:8000", ) diff --git a/examples/foundational/07j-interruptible-gladia-vad.py b/examples/foundational/07j-interruptible-gladia-vad.py index f0874f0f3..2983e1605 100644 --- a/examples/foundational/07j-interruptible-gladia-vad.py +++ b/examples/foundational/07j-interruptible-gladia-vad.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService -from pipecat.services.gladia.config import GladiaInputParams, LanguageConfig -from pipecat.services.gladia.stt import GladiaSTTService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings +from pipecat.services.gladia.config import LanguageConfig +from pipecat.services.gladia.stt import GladiaSTTService, GladiaSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -58,7 +58,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = GladiaSTTService( api_key=os.getenv("GLADIA_API_KEY", ""), region=os.getenv("GLADIA_REGION"), - params=GladiaInputParams( + settings=GladiaSTTSettings( language_config=LanguageConfig( languages=[Language.EN], ), @@ -68,19 +68,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY", ""), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY", "")) + llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY", ""), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) - messages = [ - { - "role": "system", - "content": f"You are a helpful LLM. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", - }, - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams( @@ -114,7 +112,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Please introduce yourself to the user."}) + context.add_message({"role": "system", "content": "Please introduce yourself to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/07j-interruptible-gladia.py b/examples/foundational/07j-interruptible-gladia.py index 4bebffce7..5dca15834 100644 --- a/examples/foundational/07j-interruptible-gladia.py +++ b/examples/foundational/07j-interruptible-gladia.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService -from pipecat.services.gladia.config import GladiaInputParams, LanguageConfig -from pipecat.services.gladia.stt import GladiaSTTService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings +from pipecat.services.gladia.config import LanguageConfig +from pipecat.services.gladia.stt import GladiaSTTService, GladiaSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -57,7 +57,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = GladiaSTTService( api_key=os.getenv("GLADIA_API_KEY", ""), region=os.getenv("GLADIA_REGION"), - params=GladiaInputParams( + settings=GladiaSTTSettings( language_config=LanguageConfig( languages=[Language.EN], ) @@ -66,19 +66,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY", ""), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY", "")) + llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY", ""), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) - messages = [ - { - "role": "system", - "content": f"You are a helpful LLM. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", - }, - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), @@ -109,7 +107,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Please introduce yourself to the user."}) + context.add_message({"role": "system", "content": "Please introduce yourself to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/07k-interruptible-lmnt.py b/examples/foundational/07k-interruptible-lmnt.py index 246caee19..debf186b1 100644 --- a/examples/foundational/07k-interruptible-lmnt.py +++ b/examples/foundational/07k-interruptible-lmnt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.lmnt.tts import LmntTTSService +from pipecat.services.lmnt.tts import LmntTTSService, LmntTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,7 +54,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - tts = LmntTTSService(api_key=os.getenv("LMNT_API_KEY"), voice_id="morgan") + tts = LmntTTSService( + api_key=os.getenv("LMNT_API_KEY"), + settings=LmntTTSSettings( + voice="morgan", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07l-interruptible-groq.py b/examples/foundational/07l-interruptible-groq.py index 5a16d789e..dd532b71c 100644 --- a/examples/foundational/07l-interruptible-groq.py +++ b/examples/foundational/07l-interruptible-groq.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.groq.llm import GroqLLMService +from pipecat.services.groq.llm import GroqLLMService, GroqLLMSettings from pipecat.services.groq.stt import GroqSTTService from pipecat.services.groq.tts import GroqTTSService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GroqLLMService( api_key=os.getenv("GROQ_API_KEY"), - model="meta-llama/llama-4-maverick-17b-128e-instruct", + settings=GroqLLMSettings( + model="meta-llama/llama-4-maverick-17b-128e-instruct", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/07m-interruptible-aws-strands.py b/examples/foundational/07m-interruptible-aws-strands.py index 2e0fc18d8..c65709a7b 100644 --- a/examples/foundational/07m-interruptible-aws-strands.py +++ b/examples/foundational/07m-interruptible-aws-strands.py @@ -22,7 +22,7 @@ from pipecat.processors.frameworks.strands_agents import StrandsAgentsProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.aws.stt import AWSTranscribeSTTService -from pipecat.services.aws.tts import AWSPollyTTSService +from pipecat.services.aws.tts import AWSPollyTTSService, AWSPollyTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -95,8 +95,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AWSPollyTTSService( region="us-west-2", # only specific regions support generative TTS - voice_id="Joanna", - params=AWSPollyTTSService.InputParams(engine="generative", rate="1.1"), + settings=AWSPollyTTSSettings( + voice="Joanna", + engine="generative", + rate="1.1", + ), ) # Create Strands agent processor diff --git a/examples/foundational/07m-interruptible-aws.py b/examples/foundational/07m-interruptible-aws.py index b30220bcd..48a632a35 100644 --- a/examples/foundational/07m-interruptible-aws.py +++ b/examples/foundational/07m-interruptible-aws.py @@ -22,7 +22,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.aws.llm import AWSBedrockLLMService from pipecat.services.aws.stt import AWSTranscribeSTTService -from pipecat.services.aws.tts import AWSPollyTTSService +from pipecat.services.aws.tts import AWSPollyTTSService, AWSPollyTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -54,8 +54,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AWSPollyTTSService( region="us-west-2", # only specific regions support generative TTS - voice_id="Joanna", - params=AWSPollyTTSService.InputParams(engine="generative", rate="1.1"), + settings=AWSPollyTTSSettings( + voice="Joanna", + engine="generative", + rate="1.1", + ), ) llm = AWSBedrockLLMService( diff --git a/examples/foundational/07n-interruptible-gemini-image.py b/examples/foundational/07n-interruptible-gemini-image.py index b7d3281b9..2b1d191c4 100644 --- a/examples/foundational/07n-interruptible-gemini-image.py +++ b/examples/foundational/07n-interruptible-gemini-image.py @@ -37,9 +37,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.google.llm import GoogleLLMService -from pipecat.services.google.stt import GoogleSTTService -from pipecat.services.google.tts import GoogleTTSService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings +from pipecat.services.google.stt import GoogleSTTService, GoogleSTTSettings +from pipecat.services.google.tts import GoogleTTSService, GoogleTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -70,20 +70,26 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = GoogleSTTService( - params=GoogleSTTService.InputParams(languages=Language.EN_US), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + settings=GoogleSTTSettings( + languages=Language.EN_US, + ), ) tts = GoogleTTSService( - voice_id="en-US-Chirp3-HD-Charon", - params=GoogleTTSService.InputParams(language=Language.EN_US), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + settings=GoogleTTSSettings( + voice="en-US-Chirp3-HD-Charon", + language=Language.EN_US, + ), ) llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - model="gemini-2.5-flash-image", - # model="gemini-3-pro-image-preview", # A more powerful model, but slower, + settings=GoogleLLMSettings( + model="gemini-2.5-flash-image", + # model="gemini-3-pro-image-preview", # A more powerful model, but slower, + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/07n-interruptible-gemini.py b/examples/foundational/07n-interruptible-gemini.py index 74f732926..7a631f473 100644 --- a/examples/foundational/07n-interruptible-gemini.py +++ b/examples/foundational/07n-interruptible-gemini.py @@ -23,8 +23,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.google.llm import GoogleLLMService -from pipecat.services.google.stt import GoogleSTTService -from pipecat.services.google.tts import GeminiTTSService +from pipecat.services.google.stt import GoogleSTTService, GoogleSTTSettings +from pipecat.services.google.tts import GeminiTTSService, GeminiTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,15 +54,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot with Gemini TTS") stt = GoogleSTTService( - params=GoogleSTTService.InputParams(languages=Language.EN_US), + settings=GoogleSTTSettings( + languages=Language.EN_US, + ), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), ) tts = GeminiTTSService( credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), - model="gemini-2.5-flash-tts", - voice_id="Charon", - params=GeminiTTSService.InputParams( + settings=GeminiTTSSettings( + model="gemini-2.5-flash-tts", + voice="Charon", language=Language.EN_US, prompt="You are a helpful AI assistant. Speak in a natural, conversational tone.", ), diff --git a/examples/foundational/07n-interruptible-google-http.py b/examples/foundational/07n-interruptible-google-http.py index e5f82ffc5..1f570366a 100644 --- a/examples/foundational/07n-interruptible-google-http.py +++ b/examples/foundational/07n-interruptible-google-http.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.google.llm import GoogleLLMService -from pipecat.services.google.stt import GoogleSTTService -from pipecat.services.google.tts import GoogleHttpTTSService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings +from pipecat.services.google.stt import GoogleSTTService, GoogleSTTSettings +from pipecat.services.google.tts import GoogleHttpTTSService, GoogleHttpTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,24 +54,29 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = GoogleSTTService( - params=GoogleSTTService.InputParams(languages=Language.EN_US, model="chirp_3"), + settings=GoogleSTTSettings( + languages=Language.EN_US, + model="chirp_3", + ), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), location="us", ) tts = GoogleHttpTTSService( - voice_id="en-US-Chirp3-HD-Charon", - params=GoogleHttpTTSService.InputParams(language=Language.EN_US), + settings=GoogleHttpTTSSettings( + voice="en-US-Chirp3-HD-Charon", + language=Language.EN_US, + ), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), ) llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - model="gemini-2.5-flash", - # force a certain amount of thinking if you want it - # params=GoogleLLMService.InputParams( - # thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096) - # ), + settings=GoogleLLMSettings( + model="gemini-2.5-flash", + # force a certain amount of thinking if you want it + # thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096) + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/07n-interruptible-google.py b/examples/foundational/07n-interruptible-google.py index 090fdbbdc..439676238 100644 --- a/examples/foundational/07n-interruptible-google.py +++ b/examples/foundational/07n-interruptible-google.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.google.llm import GoogleLLMService -from pipecat.services.google.stt import GoogleSTTService -from pipecat.services.google.tts import GoogleTTSService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings +from pipecat.services.google.stt import GoogleSTTService, GoogleSTTSettings +from pipecat.services.google.tts import GoogleTTSService, GoogleTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,24 +54,29 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = GoogleSTTService( - params=GoogleSTTService.InputParams(languages=Language.EN_US, model="chirp_3"), + settings=GoogleSTTSettings( + languages=Language.EN_US, + model="chirp_3", + ), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), location="us", ) tts = GoogleTTSService( - voice_id="en-US-Chirp3-HD-Charon", - params=GoogleTTSService.InputParams(language=Language.EN_US), + settings=GoogleTTSSettings( + voice="en-US-Chirp3-HD-Charon", + language=Language.EN_US, + ), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), ) llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - model="gemini-2.5-flash", - # force a certain amount of thinking if you want it - # params=GoogleLLMService.InputParams( - # thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096) - # ), + settings=GoogleLLMSettings( + model="gemini-2.5-flash", + # force a certain amount of thinking if you want it + # thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096), + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/07o-interruptible-assemblyai-turn-detection.py b/examples/foundational/07o-interruptible-assemblyai-turn-detection.py index 13f596136..b3c67f688 100644 --- a/examples/foundational/07o-interruptible-assemblyai-turn-detection.py +++ b/examples/foundational/07o-interruptible-assemblyai-turn-detection.py @@ -22,9 +22,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.assemblyai.models import AssemblyAIConnectionParams -from pipecat.services.assemblyai.stt import AssemblyAISTTService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.assemblyai.stt import AssemblyAISTTService, AssemblyAISTTSettings +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -94,7 +93,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = AssemblyAISTTService( api_key=os.getenv("ASSEMBLYAI_API_KEY"), vad_force_turn_endpoint=False, # Use AssemblyAI's built-in turn detection - connection_params=AssemblyAIConnectionParams( + settings=AssemblyAISTTSettings( speech_model="u3-rt-pro", # Optional: Tune turn detection timing (defaults shown below) # min_turn_silence=100, # Default @@ -108,7 +107,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07o-interruptible-assemblyai.py b/examples/foundational/07o-interruptible-assemblyai.py index 8378f7bba..10d6a8cd4 100644 --- a/examples/foundational/07o-interruptible-assemblyai.py +++ b/examples/foundational/07o-interruptible-assemblyai.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.assemblyai.stt import AssemblyAISTTService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07p-interruptible-krisp-viva.py b/examples/foundational/07p-interruptible-krisp-viva.py index 4df652ae0..1b10202f3 100644 --- a/examples/foundational/07p-interruptible-krisp-viva.py +++ b/examples/foundational/07p-interruptible-krisp-viva.py @@ -43,7 +43,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -84,7 +84,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), voice_id="71a7ad14-091c-4e8e-a314-022ece01c121" + api_key=os.getenv("CARTESIA_API_KEY"), + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07p-interruptible-krisp.py b/examples/foundational/07p-interruptible-krisp.py index ad737ba05..54d88d32a 100644 --- a/examples/foundational/07p-interruptible-krisp.py +++ b/examples/foundational/07p-interruptible-krisp.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -58,7 +58,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - tts = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY"), voice="aura-helios-en") + tts = DeepgramTTSService( + api_key=os.getenv("DEEPGRAM_API_KEY"), + settings=DeepgramTTSSettings( + voice="aura-helios-en", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07q-interruptible-rime-http.py b/examples/foundational/07q-interruptible-rime-http.py index 4e390b123..c735e39c9 100644 --- a/examples/foundational/07q-interruptible-rime-http.py +++ b/examples/foundational/07q-interruptible-rime-http.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.rime.tts import RimeHttpTTSService +from pipecat.services.rime.tts import RimeHttpTTSService, RimeTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -60,7 +60,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = RimeHttpTTSService( api_key=os.getenv("RIME_API_KEY", ""), - voice_id="luna", + settings=RimeTTSSettings( + voice="luna", + model="arcana", + ), model="arcana", aiohttp_session=session, ) diff --git a/examples/foundational/07q-interruptible-rime.py b/examples/foundational/07q-interruptible-rime.py index cebf6bfd0..dbc6b91e6 100644 --- a/examples/foundational/07q-interruptible-rime.py +++ b/examples/foundational/07q-interruptible-rime.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.rime.tts import RimeTTSService +from pipecat.services.rime.tts import RimeTTSService, RimeTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = RimeTTSService( api_key=os.getenv("RIME_API_KEY", ""), - voice_id="luna", + settings=RimeTTSSettings( + voice="luna", + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07r-interruptible-nvidia.py b/examples/foundational/07r-interruptible-nvidia.py index f50667267..69a5fbc15 100644 --- a/examples/foundational/07r-interruptible-nvidia.py +++ b/examples/foundational/07r-interruptible-nvidia.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.nvidia.llm import NvidiaLLMService +from pipecat.services.nvidia.llm import NvidiaLLMService, NvidiaLLMSettings from pipecat.services.nvidia.stt import NvidiaSTTService from pipecat.services.nvidia.tts import NvidiaTTSService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = NvidiaLLMService( api_key=os.getenv("NVIDIA_API_KEY"), - model="meta/llama-3.3-70b-instruct", + settings=NvidiaLLMSettings( + model="meta/llama-3.3-70b-instruct", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/07s-interruptible-google-audio-in.py b/examples/foundational/07s-interruptible-google-audio-in.py index 1de374a3f..d4067b620 100644 --- a/examples/foundational/07s-interruptible-google-audio-in.py +++ b/examples/foundational/07s-interruptible-google-audio-in.py @@ -36,8 +36,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.google.llm import GoogleLLMService -from pipecat.services.google.tts import GoogleTTSService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings +from pipecat.services.google.tts import GoogleTTSService, GoogleTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -216,7 +216,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - model="gemini-2.5-flash", + settings=GoogleLLMSettings( + model="gemini-2.5-flash", + ), # force a certain amount of thinking if you want it # params=GoogleLLMService.InputParams( # thinking=GoogleLLMService.ThinkingConfig(thinking_budget=4096) @@ -224,7 +226,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = GoogleTTSService( - voice_id="en-US-Chirp3-HD-Charon", + settings=GoogleTTSSettings( + voice="en-US-Chirp3-HD-Charon", + language=Language.EN_US, + ), params=GoogleTTSService.InputParams(language=Language.EN_US), credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), ) diff --git a/examples/foundational/07t-interruptible-fish.py b/examples/foundational/07t-interruptible-fish.py index 8b4152103..d54d34c1c 100644 --- a/examples/foundational/07t-interruptible-fish.py +++ b/examples/foundational/07t-interruptible-fish.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.fish.tts import FishAudioTTSService +from pipecat.services.fish.tts import FishAudioTTSService, FishAudioTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = FishAudioTTSService( api_key=os.getenv("FISH_API_KEY"), - model="4ce7e917cedd4bc2bb2e6ff3a46acaa1", # Barack Obama + settings=FishAudioTTSSettings( + model="4ce7e917cedd4bc2bb2e6ff3a46acaa1", # Barack Obama + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07v-interruptible-neuphonic-http.py b/examples/foundational/07v-interruptible-neuphonic-http.py index 60a08e623..081d9d6cc 100644 --- a/examples/foundational/07v-interruptible-neuphonic-http.py +++ b/examples/foundational/07v-interruptible-neuphonic-http.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.neuphonic.tts import NeuphonicHttpTTSService +from pipecat.services.neuphonic.tts import NeuphonicHttpTTSService, NeuphonicTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = NeuphonicHttpTTSService( api_key=os.getenv("NEUPHONIC_API_KEY"), - voice_id="fc854436-2dac-4d21-aa69-ae17b54e98eb", # Emily + settings=NeuphonicTTSSettings( + voice="fc854436-2dac-4d21-aa69-ae17b54e98eb", # Emily + ), aiohttp_session=session, ) diff --git a/examples/foundational/07v-interruptible-neuphonic.py b/examples/foundational/07v-interruptible-neuphonic.py index 02d6862a8..3f30ab9c7 100644 --- a/examples/foundational/07v-interruptible-neuphonic.py +++ b/examples/foundational/07v-interruptible-neuphonic.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.neuphonic.tts import NeuphonicTTSService +from pipecat.services.neuphonic.tts import NeuphonicTTSService, NeuphonicTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = NeuphonicTTSService( api_key=os.getenv("NEUPHONIC_API_KEY"), - voice_id="fc854436-2dac-4d21-aa69-ae17b54e98eb", # Emily + settings=NeuphonicTTSSettings( + voice="fc854436-2dac-4d21-aa69-ae17b54e98eb", # Emily + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07w-interruptible-fal.py b/examples/foundational/07w-interruptible-fal.py index 2d1886ddb..cbf3010d5 100644 --- a/examples/foundational/07w-interruptible-fal.py +++ b/examples/foundational/07w-interruptible-fal.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.fal.stt import FalSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07x-interruptible-local.py b/examples/foundational/07x-interruptible-local.py index 3465f67b2..63cf2bbb1 100644 --- a/examples/foundational/07x-interruptible-local.py +++ b/examples/foundational/07x-interruptible-local.py @@ -21,7 +21,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMContextAggregatorPair, LLMUserAggregatorParams, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.local.audio import LocalAudioTransport, LocalAudioTransportParams @@ -44,7 +44,9 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07y-interruptible-minimax.py b/examples/foundational/07y-interruptible-minimax.py index f23d86f34..690c35178 100644 --- a/examples/foundational/07y-interruptible-minimax.py +++ b/examples/foundational/07y-interruptible-minimax.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.minimax.tts import MiniMaxHttpTTSService +from pipecat.services.minimax.tts import MiniMaxHttpTTSService, MiniMaxTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): api_key=os.getenv("MINIMAX_API_KEY", ""), group_id=os.getenv("MINIMAX_GROUP_ID", ""), aiohttp_session=session, - params=MiniMaxHttpTTSService.InputParams(language=Language.EN), + settings=MiniMaxTTSSettings( + language=Language.EN, + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07z-interruptible-sarvam-http.py b/examples/foundational/07z-interruptible-sarvam-http.py index 1f9a8a4e3..33f1277e6 100644 --- a/examples/foundational/07z-interruptible-sarvam-http.py +++ b/examples/foundational/07z-interruptible-sarvam-http.py @@ -25,7 +25,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.sarvam.stt import SarvamSTTService -from pipecat.services.sarvam.tts import SarvamHttpTTSService +from pipecat.services.sarvam.tts import SarvamHttpTTSService, SarvamHttpTTSSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -65,7 +65,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = SarvamHttpTTSService( api_key=os.getenv("SARVAM_API_KEY"), aiohttp_session=session, - params=SarvamHttpTTSService.InputParams(language=Language.EN), + settings=SarvamHttpTTSSettings( + language=Language.EN, + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07z-interruptible-sarvam.py b/examples/foundational/07z-interruptible-sarvam.py index a9a03e7d4..60b5bcc8b 100644 --- a/examples/foundational/07z-interruptible-sarvam.py +++ b/examples/foundational/07z-interruptible-sarvam.py @@ -22,8 +22,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.sarvam.stt import SarvamSTTService -from pipecat.services.sarvam.tts import SarvamTTSService +from pipecat.services.sarvam.stt import SarvamSTTService, SarvamSTTSettings +from pipecat.services.sarvam.tts import SarvamTTSService, SarvamTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -54,13 +54,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = SarvamSTTService( api_key=os.getenv("SARVAM_API_KEY"), - model="saarika:v2.5", + settings=SarvamSTTSettings( + model="saarika:v2.5", + ), ) tts = SarvamTTSService( api_key=os.getenv("SARVAM_API_KEY"), - model="bulbul:v2", - voice_id="manisha", + settings=SarvamTTSSettings( + model="bulbul:v2", + voice="manisha", + ), ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07za-interruptible-soniox.py b/examples/foundational/07za-interruptible-soniox.py index f2d651e5b..56b2dee1e 100644 --- a/examples/foundational/07za-interruptible-soniox.py +++ b/examples/foundational/07za-interruptible-soniox.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.soniox.stt import SonioxInputParams, SonioxSTTService +from pipecat.services.soniox.stt import SonioxSTTService, SonioxSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -51,17 +51,21 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = SonioxSTTService( - api_key=os.getenv("SONIOX_API_KEY"), - params=SonioxInputParams( - language_hints=[Language.EN], - language_hints_strict=True, + stt = ( + SonioxSTTService( + api_key=os.getenv("SONIOX_API_KEY"), + settings=SonioxSTTSettings( + language_hints=[Language.EN], + language_hints_strict=True, + ), ), ) tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07zb-interruptible-inworld-http.py b/examples/foundational/07zb-interruptible-inworld-http.py index 9ef465781..ffbdbb444 100644 --- a/examples/foundational/07zb-interruptible-inworld-http.py +++ b/examples/foundational/07zb-interruptible-inworld-http.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.inworld.tts import InworldHttpTTSService +from pipecat.services.inworld.tts import InworldHttpTTSService, InworldTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_output import BaseOutputTransport from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -58,10 +58,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = InworldHttpTTSService( api_key=os.getenv("INWORLD_API_KEY", ""), aiohttp_session=session, - voice_id="Ashley", - model="inworld-tts-1", - # Set to False for non-streaming mode or True for streaming mode. streaming=True, + settings=InworldTTSSettings( + voice="Ashley", + model="inworld-tts-1", + ), + # Set to False for non-streaming mode or True for streaming mode. ) llm = OpenAILLMService( diff --git a/examples/foundational/07zb-interruptible-inworld.py b/examples/foundational/07zb-interruptible-inworld.py index 7cdbfd88a..6c8b53706 100644 --- a/examples/foundational/07zb-interruptible-inworld.py +++ b/examples/foundational/07zb-interruptible-inworld.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.inworld.tts import InworldTTSService +from pipecat.services.inworld.tts import InworldTTSService, InworldTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_output import BaseOutputTransport from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -56,9 +56,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = InworldTTSService( api_key=os.getenv("INWORLD_API_KEY", ""), - voice_id="Ashley", - model="inworld-tts-1", - temperature=1.1, + settings=InworldTTSSettings( + voice="Ashley", + model="inworld-tts-1", + temperature=1.1, + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07zc-interruptible-asyncai-http.py b/examples/foundational/07zc-interruptible-asyncai-http.py index 17d187ac8..3246feac4 100644 --- a/examples/foundational/07zc-interruptible-asyncai-http.py +++ b/examples/foundational/07zc-interruptible-asyncai-http.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.asyncai.tts import AsyncAIHttpTTSService +from pipecat.services.asyncai.tts import AsyncAIHttpTTSService, AsyncAITTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AsyncAIHttpTTSService( api_key=os.getenv("ASYNCAI_API_KEY", ""), - voice_id=os.getenv("ASYNCAI_VOICE_ID", "e0f39dc4-f691-4e78-bba5-5c636692cc04"), + settings=AsyncAITTSSettings( + voice="e0f39dc4-f691-4e78-bba5-5c636692cc04", + ), aiohttp_session=session, ) diff --git a/examples/foundational/07zc-interruptible-asyncai.py b/examples/foundational/07zc-interruptible-asyncai.py index 799842658..093f03ccb 100644 --- a/examples/foundational/07zc-interruptible-asyncai.py +++ b/examples/foundational/07zc-interruptible-asyncai.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.asyncai.tts import AsyncAITTSService +from pipecat.services.asyncai.tts import AsyncAITTSService, AsyncAITTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AsyncAITTSService( api_key=os.getenv("ASYNCAI_API_KEY", ""), - voice_id=os.getenv("ASYNCAI_VOICE_ID", "e0f39dc4-f691-4e78-bba5-5c636692cc04"), + settings=AsyncAITTSSettings( + voice="e0f39dc4-f691-4e78-bba5-5c636692cc04", + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07zd-interruptible-aicoustics.py b/examples/foundational/07zd-interruptible-aicoustics.py index 9e9f6ddd6..cedb95a9e 100644 --- a/examples/foundational/07zd-interruptible-aicoustics.py +++ b/examples/foundational/07zd-interruptible-aicoustics.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.audio.audio_buffer_processor import AudioBufferProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -77,7 +77,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07ze-interruptible-hume.py b/examples/foundational/07ze-interruptible-hume.py index 395aa75d4..70ace62e9 100644 --- a/examples/foundational/07ze-interruptible-hume.py +++ b/examples/foundational/07ze-interruptible-hume.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.hume.tts import HUME_SAMPLE_RATE, HumeTTSService +from pipecat.services.hume.tts import HUME_SAMPLE_RATE, HumeTTSService, HumeTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_output import BaseOutputTransport from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = HumeTTSService( api_key=os.getenv("HUME_API_KEY"), # Replace with your Hume voice ID - voice_id="f898a92e-685f-43fa-985b-a46920f0650b", + settings=HumeTTSSettings( + voice="f898a92e-685f-43fa-985b-a46920f0650b", + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07zf-interruptible-gradium.py b/examples/foundational/07zf-interruptible-gradium.py index d76735897..ff164c790 100644 --- a/examples/foundational/07zf-interruptible-gradium.py +++ b/examples/foundational/07zf-interruptible-gradium.py @@ -21,8 +21,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.gradium.stt import GradiumSTTService -from pipecat.services.gradium.tts import GradiumTTSService +from pipecat.services.gradium.stt import GradiumSTTService, GradiumSTTSettings +from pipecat.services.gradium.tts import GradiumTTSService, GradiumTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -55,15 +55,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = GradiumSTTService( api_key=os.getenv("GRADIUM_API_KEY"), api_endpoint_base_url="wss://us.api.gradium.ai/api/speech/asr", - params=GradiumSTTService.InputParams( + settings=GradiumSTTSettings( language=Language.EN, ), ) tts = GradiumTTSService( api_key=os.getenv("GRADIUM_API_KEY"), - voice_id="YTpq7expH9539ERJ", url="wss://us.api.gradium.ai/api/speech/tts", + settings=GradiumTTSSettings( + voice="YTpq7expH9539ERJ", + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07zg-interruptible-camb.py b/examples/foundational/07zg-interruptible-camb.py index 669315603..f98303b26 100644 --- a/examples/foundational/07zg-interruptible-camb.py +++ b/examples/foundational/07zg-interruptible-camb.py @@ -21,7 +21,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.camb.tts import CambTTSService +from pipecat.services.camb.tts import CambTTSService, CambTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CambTTSService( api_key=os.getenv("CAMB_API_KEY"), - model="mars-flash", + settings=CambTTSSettings( + model="mars-flash", + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/07zi-interruptible-piper.py b/examples/foundational/07zi-interruptible-piper.py index 9d07f9cdf..fb38cba6a 100644 --- a/examples/foundational/07zi-interruptible-piper.py +++ b/examples/foundational/07zi-interruptible-piper.py @@ -23,7 +23,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.piper.tts import PiperTTSService +from pipecat.services.piper.tts import PiperTTSService, PiperTTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -54,7 +54,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - tts = PiperTTSService(voice_id="en_US-ryan-high") + tts = PiperTTSService( + settings=PiperTTSSettings( + voice="en_US-ryan-high", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07zj-interruptible-kokoro.py b/examples/foundational/07zj-interruptible-kokoro.py index 04ab90145..7271ef42d 100644 --- a/examples/foundational/07zj-interruptible-kokoro.py +++ b/examples/foundational/07zj-interruptible-kokoro.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.kokoro.tts import KokoroTTSService +from pipecat.services.kokoro.tts import KokoroTTSService, KokoroTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,7 +54,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - tts = KokoroTTSService(voice_id="af_heart") + tts = KokoroTTSService( + settings=KokoroTTSSettings( + voice="af_heart", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/07zk-interruptible-resemble.py b/examples/foundational/07zk-interruptible-resemble.py index d9298815d..5e89eaa6e 100644 --- a/examples/foundational/07zk-interruptible-resemble.py +++ b/examples/foundational/07zk-interruptible-resemble.py @@ -23,7 +23,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.resembleai.tts import ResembleAITTSService +from pipecat.services.resembleai.tts import ResembleAITTSService, ResembleAITTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ResembleAITTSService( api_key=os.getenv("RESEMBLE_API_KEY"), - voice_id=os.getenv("RESEMBLE_VOICE_UUID"), + settings=ResembleAITTSSettings( + voice=os.getenv("RESEMBLE_VOICE_UUID"), + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/08-custom-frame-processor.py b/examples/foundational/08-custom-frame-processor.py index a4b5b2127..cfab184cb 100644 --- a/examples/foundational/08-custom-frame-processor.py +++ b/examples/foundational/08-custom-frame-processor.py @@ -26,7 +26,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -95,7 +95,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/10-wake-phrase.py b/examples/foundational/10-wake-phrase.py index 52a7d1225..a57ef6f96 100644 --- a/examples/foundational/10-wake-phrase.py +++ b/examples/foundational/10-wake-phrase.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.filters.wake_check_filter import WakeCheckFilter from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/11-sound-effects.py b/examples/foundational/11-sound-effects.py index 401c36b8e..332c1536a 100644 --- a/examples/foundational/11-sound-effects.py +++ b/examples/foundational/11-sound-effects.py @@ -30,7 +30,7 @@ from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.processors.logger import FrameLogger from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -111,7 +111,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) context = LLMContext() diff --git a/examples/foundational/12-describe-image-openai.py b/examples/foundational/12-describe-image-openai.py index dc45451fe..4d22e4046 100644 --- a/examples/foundational/12-describe-image-openai.py +++ b/examples/foundational/12-describe-image-openai.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -53,7 +53,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/12a-describe-image-anthropic.py b/examples/foundational/12a-describe-image-anthropic.py index a1151ddf9..79e4460a2 100644 --- a/examples/foundational/12a-describe-image-anthropic.py +++ b/examples/foundational/12a-describe-image-anthropic.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -53,7 +53,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AnthropicLLMService( diff --git a/examples/foundational/12b-describe-image-aws.py b/examples/foundational/12b-describe-image-aws.py index 43a6ae232..b4db59409 100644 --- a/examples/foundational/12b-describe-image-aws.py +++ b/examples/foundational/12b-describe-image-aws.py @@ -23,8 +23,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.aws.llm import AWSBedrockLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.aws.llm import AWSBedrockLLMService, AWSBedrockLLMSettings +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -53,16 +53,20 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AWSBedrockLLMService( aws_region="us-west-2", - model="us.anthropic.claude-3-7-sonnet-20250219-v1:0", - # Note: usually, prefer providing latency="optimized" param. - # Here we can't because AWS Bedrock doesn't support it for Claude 3.7, - # which we need for image input. - params=AWSBedrockLLMService.InputParams(temperature=0.8), + settings=AWSBedrockLLMSettings( + model="us.anthropic.claude-3-7-sonnet-20250219-v1:0", + # Note: usually, prefer providing latency="optimized" param. + # Here we can't because AWS Bedrock doesn't support it for Claude 3.7, + # which we need for image input. + params=AWSBedrockLLMService.InputParams(temperature=0.8), + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are also able to describe images.", ) diff --git a/examples/foundational/12c-describe-image-gemini-flash.py b/examples/foundational/12c-describe-image-gemini-flash.py index 9adbe62d2..1f550dd6f 100644 --- a/examples/foundational/12c-describe-image-gemini-flash.py +++ b/examples/foundational/12c-describe-image-gemini-flash.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -53,7 +53,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/12d-describe-image-moondream.py b/examples/foundational/12d-describe-image-moondream.py index 070b004a1..21fc79ed5 100644 --- a/examples/foundational/12d-describe-image-moondream.py +++ b/examples/foundational/12d-describe-image-moondream.py @@ -17,7 +17,7 @@ from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.moondream.vision import MoondreamService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -42,7 +42,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) vision = MoondreamService() diff --git a/examples/foundational/13b-deepgram-transcription.py b/examples/foundational/13b-deepgram-transcription.py index ed83bd1d5..61ba5c266 100644 --- a/examples/foundational/13b-deepgram-transcription.py +++ b/examples/foundational/13b-deepgram-transcription.py @@ -16,7 +16,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.deepgram.stt import DeepgramSTTService, Language, LiveOptions +from pipecat.services.deepgram.stt import DeepgramSTTService, DeepgramSTTSettings, Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -49,7 +49,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService( api_key=os.getenv("DEEPGRAM_API_KEY"), - live_options=LiveOptions(language=Language.EN), + settings=DeepgramSTTSettings( + language=Language.EN, + ), ) tl = TranscriptionLogger() diff --git a/examples/foundational/13c-gladia-transcription.py b/examples/foundational/13c-gladia-transcription.py index c98fda727..8771cb8d4 100644 --- a/examples/foundational/13c-gladia-transcription.py +++ b/examples/foundational/13c-gladia-transcription.py @@ -50,7 +50,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = GladiaSTTService( api_key=os.getenv("GLADIA_API_KEY"), region=os.getenv("GLADIA_REGION"), - # live_options=LiveOptions(language=Language.FR), + # settings=GladiaSTTSettings( + # language_config=LanguageConfig( + # languages=[Language.FR], + # ), + # ), ) tl = TranscriptionLogger() diff --git a/examples/foundational/13c-gladia-translation.py b/examples/foundational/13c-gladia-translation.py index edc294858..9f7b6a6da 100644 --- a/examples/foundational/13c-gladia-translation.py +++ b/examples/foundational/13c-gladia-translation.py @@ -22,7 +22,7 @@ from pipecat.services.gladia.config import ( RealtimeProcessingConfig, TranslationConfig, ) -from pipecat.services.gladia.stt import GladiaSTTService +from pipecat.services.gladia.stt import GladiaSTTService, GladiaSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -59,16 +59,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = GladiaSTTService( api_key=os.getenv("GLADIA_API_KEY"), region=os.getenv("GLADIA_REGION"), - params=GladiaInputParams( + settings=GladiaSTTSettings( language_config=LanguageConfig( - languages=[Language.EN], # Input in English + languages=[Language.EN], code_switching=False, ), realtime_processing=RealtimeProcessingConfig( - translation=True, # Enable translation + translation=True, translation_config=TranslationConfig( - target_languages=[Language.ES], # Translate to Spanish - model="enhanced", # Use the enhanced translation model + target_languages=[Language.ES], + model="enhanced", ), ), ), diff --git a/examples/foundational/13d-assemblyai-transcription.py b/examples/foundational/13d-assemblyai-transcription.py index 2dcbaf59b..c4ca9cd6b 100644 --- a/examples/foundational/13d-assemblyai-transcription.py +++ b/examples/foundational/13d-assemblyai-transcription.py @@ -16,8 +16,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.assemblyai.models import AssemblyAIConnectionParams -from pipecat.services.assemblyai.stt import AssemblyAISTTService +from pipecat.services.assemblyai.stt import AssemblyAISTTService, AssemblyAISTTSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -50,8 +49,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = AssemblyAISTTService( api_key=os.getenv("ASSEMBLYAI_API_KEY"), - connection_params=AssemblyAIConnectionParams( - speech_model="u3-rt-pro", + settings=AssemblyAISTTSettings( + model="u3-rt-pro", ), ) diff --git a/examples/foundational/13e-whisper-mlx.py b/examples/foundational/13e-whisper-mlx.py index ba90d0850..0f11d4397 100644 --- a/examples/foundational/13e-whisper-mlx.py +++ b/examples/foundational/13e-whisper-mlx.py @@ -18,7 +18,7 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.whisper.stt import MLXModel, WhisperSTTServiceMLX +from pipecat.services.whisper.stt import MLXModel, WhisperMLXSTTSettings, WhisperSTTServiceMLX from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -77,7 +77,11 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = WhisperSTTServiceMLX(model=MLXModel.LARGE_V3_TURBO) + stt = WhisperSTTServiceMLX( + settings=WhisperMLXSTTSettings( + model=MLXModel.LARGE_V3_TURBO, + ), + ) tl = TranscriptionLogger() diff --git a/examples/foundational/13g-sambanova-transcription.py b/examples/foundational/13g-sambanova-transcription.py index cebeea615..1e399c38f 100644 --- a/examples/foundational/13g-sambanova-transcription.py +++ b/examples/foundational/13g-sambanova-transcription.py @@ -19,7 +19,7 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.sambanova.stt import SambaNovaSTTService +from pipecat.services.sambanova.stt import SambaNovaSTTService, SambaNovaSTTSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -79,7 +79,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = SambaNovaSTTService( - model="Whisper-Large-v3", + settings=SambaNovaSTTSettings( + model="Whisper-Large-v3", + ), api_key=os.getenv("SAMBANOVA_API_KEY"), ) diff --git a/examples/foundational/13h-speechmatics-transcription.py b/examples/foundational/13h-speechmatics-transcription.py index f1d1d93c6..d013357f6 100644 --- a/examples/foundational/13h-speechmatics-transcription.py +++ b/examples/foundational/13h-speechmatics-transcription.py @@ -16,7 +16,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.speechmatics.stt import SpeechmaticsSTTService +from pipecat.services.speechmatics.stt import SpeechmaticsSTTService, SpeechmaticsSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -65,7 +65,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = SpeechmaticsSTTService( api_key=os.getenv("SPEECHMATICS_API_KEY"), - params=SpeechmaticsSTTService.InputParams( + settings=SpeechmaticsSTTSettings( language=Language.EN, speaker_active_format="<{speaker_id}>{text}", ), diff --git a/examples/foundational/13l-gradium-transcription.py b/examples/foundational/13l-gradium-transcription.py index 38709dff7..84b23017c 100644 --- a/examples/foundational/13l-gradium-transcription.py +++ b/examples/foundational/13l-gradium-transcription.py @@ -16,7 +16,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.gradium.stt import GradiumSTTService +from pipecat.services.gradium.stt import GradiumSTTService, GradiumSTTSettings from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -52,7 +52,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = GradiumSTTService( api_key=os.getenv("GRADIUM_API_KEY"), api_endpoint_base_url="wss://us.api.gradium.ai/api/speech/asr", - params=GradiumSTTService.InputParams(language=Language.EN, delay_in_frames=8), + settings=GradiumSTTSettings( + language=Language.EN, + delay_in_frames=8, + ), ) tl = TranscriptionLogger() diff --git a/examples/foundational/13m-openai-transcription.py b/examples/foundational/13m-openai-transcription.py index 2ef35cb3f..8dc9e0101 100644 --- a/examples/foundational/13m-openai-transcription.py +++ b/examples/foundational/13m-openai-transcription.py @@ -18,7 +18,7 @@ from pipecat.pipeline.task import PipelineTask from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.openai.stt import OpenAIRealtimeSTTService +from pipecat.services.openai.stt import OpenAIRealtimeSTTService, OpenAIRealtimeSTTSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -53,8 +53,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = OpenAIRealtimeSTTService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o-transcribe", - prompt="Expect words related to dogs, such as breed names.", + settings=OpenAIRealtimeSTTSettings( + model="gpt-4o-transcribe", + prompt="Expect words related to dogs, such as breed names.", + ), ) tl = TranscriptionLogger() diff --git a/examples/foundational/14-function-calling.py b/examples/foundational/14-function-calling.py index 0087af9fc..2a3206dbc 100644 --- a/examples/foundational/14-function-calling.py +++ b/examples/foundational/14-function-calling.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/14a-function-calling-anthropic.py b/examples/foundational/14a-function-calling-anthropic.py index 36030bc2b..0fd40af4f 100644 --- a/examples/foundational/14a-function-calling-anthropic.py +++ b/examples/foundational/14a-function-calling-anthropic.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -69,10 +69,15 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = AnthropicLLMService(api_key=os.getenv("ANTHROPIC_API_KEY")) + llm = AnthropicLLMService( + api_key=os.getenv("ANTHROPIC_API_KEY"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) llm.register_function("get_weather", get_weather) llm.register_function("get_restaurant_recommendation", fetch_restaurant_recommendation) @@ -100,16 +105,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tools = ToolsSchema(standard_tools=[weather_function, restaurant_function]) - # todo: test with very short initial user message - - # messages = [{"role": "system", - # "content": "You are a helpful assistant who can report the weather in any location in the universe. Respond concisely. Your response will be turned into speech so use only simple words and punctuation."}, - # {"role": "user", - # "content": " Start the conversation by introducing yourself."}] - - messages = [{"role": "user", "content": "Say 'hello' to start the conversation."}] - - context = LLMContext(messages, tools) + context = LLMContext(tools=tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/14c-function-calling-together.py b/examples/foundational/14c-function-calling-together.py index 214d6f292..6362e1ea6 100644 --- a/examples/foundational/14c-function-calling-together.py +++ b/examples/foundational/14c-function-calling-together.py @@ -24,10 +24,10 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.together.llm import TogetherLLMService +from pipecat.services.together.llm import TogetherLLMService, TogetherLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -64,12 +64,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = TogetherLLMService( api_key=os.getenv("TOGETHER_API_KEY"), - model="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo", + settings=TogetherLLMSettings( + model="meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14d-function-calling-anthropic-video.py b/examples/foundational/14d-function-calling-anthropic-video.py index cddde3647..fee17734c 100644 --- a/examples/foundational/14d-function-calling-anthropic-video.py +++ b/examples/foundational/14d-function-calling-anthropic-video.py @@ -29,7 +29,7 @@ from pipecat.runner.utils import ( maybe_capture_participant_camera, ) from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -90,7 +90,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # Anthropic for vision analysis diff --git a/examples/foundational/14d-function-calling-aws-video.py b/examples/foundational/14d-function-calling-aws-video.py index 396ea0a32..234552d92 100644 --- a/examples/foundational/14d-function-calling-aws-video.py +++ b/examples/foundational/14d-function-calling-aws-video.py @@ -28,8 +28,8 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.aws.llm import AWSBedrockLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.aws.llm import AWSBedrockLLMService, AWSBedrockLLMSettings +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -90,17 +90,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # AWS for vision analysis llm = AWSBedrockLLMService( aws_region="us-west-2", - model="us.anthropic.claude-3-7-sonnet-20250219-v1:0", - # Note: usually, prefer providing latency="optimized" param. - # Here we can't because AWS Bedrock doesn't support it for Claude 3.7, - # which we need for image input. - params=AWSBedrockLLMService.InputParams(temperature=0.8), + settings=AWSBedrockLLMSettings( + model="us.anthropic.claude-3-7-sonnet-20250219-v1:0", + # Note: usually, prefer providing latency="optimized" param. + # Here we can't because AWS Bedrock doesn't support it for Claude 3.7, + # which we need for image input. + temperature=0.8, + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way. You are able to describe images from the user camera.", ) llm.register_function("fetch_user_image", fetch_user_image) diff --git a/examples/foundational/14d-function-calling-gemini-flash-video.py b/examples/foundational/14d-function-calling-gemini-flash-video.py index c59767406..f1255d287 100644 --- a/examples/foundational/14d-function-calling-gemini-flash-video.py +++ b/examples/foundational/14d-function-calling-gemini-flash-video.py @@ -28,7 +28,7 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.llm_service import FunctionCallParams @@ -90,7 +90,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # Google Gemini model for vision analysis diff --git a/examples/foundational/14d-function-calling-moondream-video.py b/examples/foundational/14d-function-calling-moondream-video.py index d0913e3dc..6ffb10213 100644 --- a/examples/foundational/14d-function-calling-moondream-video.py +++ b/examples/foundational/14d-function-calling-moondream-video.py @@ -37,7 +37,7 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.moondream.vision import MoondreamService @@ -121,7 +121,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/14d-function-calling-openai-video.py b/examples/foundational/14d-function-calling-openai-video.py index 50365eb29..235815a5c 100644 --- a/examples/foundational/14d-function-calling-openai-video.py +++ b/examples/foundational/14d-function-calling-openai-video.py @@ -29,7 +29,7 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -91,7 +91,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/14e-function-calling-google.py b/examples/foundational/14e-function-calling-google.py index cae32146e..08308dee3 100644 --- a/examples/foundational/14e-function-calling-google.py +++ b/examples/foundational/14e-function-calling-google.py @@ -29,7 +29,7 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.llm_service import FunctionCallParams @@ -100,10 +100,34 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY")) + system_prompt = """\ +You are a helpful assistant who converses with a user and answers questions. Respond concisely to general questions. + +Your response will be turned into speech so use only simple words and punctuation. + +You have access to three tools: get_weather, get_restaurant_recommendation, and get_image. + +You can respond to questions about the weather using the get_weather tool. + +You can answer questions about the user's video stream using the get_image tool. Some examples of phrases that \ +indicate you should use the get_image tool are: +- What do you see? +- What's in the video? +- Can you describe the video? +- Tell me about what you see. +- Tell me something interesting about what you see. +- What's happening in the video? +""" + + llm = GoogleLLMService( + api_key=os.getenv("GOOGLE_API_KEY"), + system_instruction=system_prompt, + ) llm.register_function("get_weather", get_weather) llm.register_function("get_image", get_image) llm.register_function("get_restaurant_recommendation", fetch_restaurant_recommendation) @@ -156,29 +180,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tools = ToolsSchema(standard_tools=[weather_function, get_image_function, restaurant_function]) - system_prompt = """\ -You are a helpful assistant who converses with a user and answers questions. Respond concisely to general questions. - -Your response will be turned into speech so use only simple words and punctuation. - -You have access to three tools: get_weather, get_restaurant_recommendation, and get_image. - -You can respond to questions about the weather using the get_weather tool. - -You can answer questions about the user's video stream using the get_image tool. Some examples of phrases that \ -indicate you should use the get_image tool are: -- What do you see? -- What's in the video? -- Can you describe the video? -- Tell me about what you see. -- Tell me something interesting about what you see. -- What's happening in the video? -""" - messages = [ - {"role": "system", "content": system_prompt}, - ] - - context = LLMContext(messages, tools) + context = LLMContext(tools=tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), @@ -214,9 +216,9 @@ indicate you should use the get_image tool are: client_id = get_transport_client_id(transport, client) # Kick off the conversation. - messages.append( + context.add_message( { - "role": "system", + "role": "user", "content": f"Please introduce yourself to the user. Use '{client_id}' as the user ID during function calls.", } ) diff --git a/examples/foundational/14f-function-calling-groq.py b/examples/foundational/14f-function-calling-groq.py index e6cfb3659..11bbda12d 100644 --- a/examples/foundational/14f-function-calling-groq.py +++ b/examples/foundational/14f-function-calling-groq.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.groq.llm import GroqLLMService from pipecat.services.groq.stt import GroqSTTService from pipecat.services.llm_service import FunctionCallParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GroqLLMService( diff --git a/examples/foundational/14g-function-calling-grok.py b/examples/foundational/14g-function-calling-grok.py index 51435a2a0..7ff89658d 100644 --- a/examples/foundational/14g-function-calling-grok.py +++ b/examples/foundational/14g-function-calling-grok.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.grok.llm import GrokLLMService from pipecat.services.llm_service import FunctionCallParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GrokLLMService( diff --git a/examples/foundational/14h-function-calling-azure.py b/examples/foundational/14h-function-calling-azure.py index 192cebb92..9df6abeef 100644 --- a/examples/foundational/14h-function-calling-azure.py +++ b/examples/foundational/14h-function-calling-azure.py @@ -24,8 +24,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.azure.llm import AzureLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.azure.llm import AzureLLMService, AzureLLMSettings +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -64,13 +64,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AzureLLMService( api_key=os.getenv("AZURE_CHATGPT_API_KEY"), endpoint=os.getenv("AZURE_CHATGPT_ENDPOINT"), - model=os.getenv("AZURE_CHATGPT_MODEL"), + settings=AzureLLMSettings( + model=os.getenv("AZURE_CHATGPT_MODEL"), + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14i-function-calling-fireworks.py b/examples/foundational/14i-function-calling-fireworks.py index be006e062..6a274c09f 100644 --- a/examples/foundational/14i-function-calling-fireworks.py +++ b/examples/foundational/14i-function-calling-fireworks.py @@ -24,9 +24,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.fireworks.llm import FireworksLLMService +from pipecat.services.fireworks.llm import FireworksLLMService, FireworksLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -64,12 +64,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = FireworksLLMService( api_key=os.getenv("FIREWORKS_API_KEY"), - model="accounts/fireworks/models/gpt-oss-20b", + settings=FireworksLLMSettings( + model="accounts/fireworks/models/gpt-oss-20b", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14j-function-calling-nvidia.py b/examples/foundational/14j-function-calling-nvidia.py index e079c228f..680952d75 100644 --- a/examples/foundational/14j-function-calling-nvidia.py +++ b/examples/foundational/14j-function-calling-nvidia.py @@ -24,10 +24,10 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.nvidia.llm import NvidiaLLMService +from pipecat.services.nvidia.llm import NvidiaLLMService, NvidiaLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -64,15 +64,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady - # text_filters=[MarkdownTextFilter()], + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = NvidiaLLMService( api_key=os.getenv("NVIDIA_API_KEY"), - model="nvidia/llama-3.3-nemotron-super-49b-v1.5", - # Recommended when turning thinking off - params=NvidiaLLMService.InputParams(temperature=0.0), + settings=NvidiaLLMSettings( + model="nvidia/llama-3.3-nemotron-super-49b-v1.5", + # Recommended when turning thinking off + temperature=0.0, + ), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. @@ -99,17 +103,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): required=["location", "format"], ) tools = ToolsSchema(standard_tools=[weather_function]) - messages = [ - # Disable thinking by sending this message first - # Check the model for the corresponding "no thinking" message - {"role": "system", "content": "/no_think"}, - { - "role": "system", - "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", - }, - ] - context = LLMContext(messages, tools) + context = LLMContext(tools=tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/14k-function-calling-cerebras.py b/examples/foundational/14k-function-calling-cerebras.py index 81df8723c..118062769 100644 --- a/examples/foundational/14k-function-calling-cerebras.py +++ b/examples/foundational/14k-function-calling-cerebras.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.cerebras.llm import CerebrasLLMService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = CerebrasLLMService( diff --git a/examples/foundational/14l-function-calling-deepseek.py b/examples/foundational/14l-function-calling-deepseek.py index 93643146a..9c2068236 100644 --- a/examples/foundational/14l-function-calling-deepseek.py +++ b/examples/foundational/14l-function-calling-deepseek.py @@ -24,9 +24,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepseek.llm import DeepSeekLLMService +from pipecat.services.deepseek.llm import DeepSeekLLMService, DeepSeekLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -64,12 +64,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = DeepSeekLLMService( api_key=os.getenv("DEEPSEEK_API_KEY"), - model="deepseek-chat", + settings=DeepSeekLLMSettings( + model="deepseek-chat", + ), system_instruction="""You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. You have one functions available: diff --git a/examples/foundational/14m-function-calling-openrouter.py b/examples/foundational/14m-function-calling-openrouter.py index 9504021ff..dbcd1813f 100644 --- a/examples/foundational/14m-function-calling-openrouter.py +++ b/examples/foundational/14m-function-calling-openrouter.py @@ -24,10 +24,10 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.azure.tts import AzureTTSService +from pipecat.services.azure.tts import AzureTTSService, AzureTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.openrouter.llm import OpenRouterLLMService +from pipecat.services.openrouter.llm import OpenRouterLLMService, OpenRouterLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -65,13 +65,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AzureTTSService( api_key=os.getenv("AZURE_SPEECH_API_KEY"), region=os.getenv("AZURE_SPEECH_REGION"), - voice="en-US-JennyNeural", - params=AzureTTSService.InputParams(language="en-US", rate="1.1", style="cheerful"), + settings=AzureTTSSettings( + voice="en-US-JennyNeural", + language="en-US", + rate="1.1", + style="cheerful", + ), ) llm = OpenRouterLLMService( api_key=os.getenv("OPENROUTER_API_KEY"), - model="openai/gpt-4o-2024-11-20", + settings=OpenRouterLLMSettings( + model="openai/gpt-4o-2024-11-20", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can also register a function_name of None to get all functions diff --git a/examples/foundational/14n-function-calling-perplexity.py b/examples/foundational/14n-function-calling-perplexity.py index 2f1a18d52..4857b614f 100644 --- a/examples/foundational/14n-function-calling-perplexity.py +++ b/examples/foundational/14n-function-calling-perplexity.py @@ -28,7 +28,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.perplexity.llm import PerplexityLLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -62,19 +62,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = PerplexityLLMService(api_key=os.getenv("PERPLEXITY_API_KEY")) + llm = PerplexityLLMService( + api_key=os.getenv("PERPLEXITY_API_KEY"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way, but try to be brief.", + ) - messages = [ - { - "role": "user", - "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way, but try to be brief.", - }, - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/14o-function-calling-gemini-openai-format.py b/examples/foundational/14o-function-calling-gemini-openai-format.py index c3772eb2c..4a752586f 100644 --- a/examples/foundational/14o-function-calling-gemini-openai-format.py +++ b/examples/foundational/14o-function-calling-gemini-openai-format.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.elevenlabs.tts import ElevenLabsTTSService +from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings from pipecat.services.google.llm_openai import GoogleLLMOpenAIBetaService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -64,10 +64,15 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), - voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + settings=ElevenLabsTTSSettings( + voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + ), ) - llm = GoogleLLMOpenAIBetaService(api_key=os.getenv("GOOGLE_API_KEY")) + llm = GoogleLLMOpenAIBetaService( + api_key=os.getenv("GOOGLE_API_KEY"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) # You can aslo register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. llm.register_function("get_current_weather", fetch_weather_from_api) diff --git a/examples/foundational/14p-function-calling-gemini-vertex-ai.py b/examples/foundational/14p-function-calling-gemini-vertex-ai.py index a71f3c8d1..3ff062201 100644 --- a/examples/foundational/14p-function-calling-gemini-vertex-ai.py +++ b/examples/foundational/14p-function-calling-gemini-vertex-ai.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.elevenlabs.tts import ElevenLabsTTSService +from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings from pipecat.services.google.llm_vertex import GoogleVertexLLMService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -64,13 +64,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), - voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + settings=ElevenLabsTTSSettings( + voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + ), ) llm = GoogleVertexLLMService( credentials=os.getenv("GOOGLE_VERTEX_TEST_CREDENTIALS"), project_id=os.getenv("GOOGLE_CLOUD_PROJECT_ID"), location=os.getenv("GOOGLE_CLOUD_LOCATION"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # You can aslo register a function_name of None to get all functions # sent to the same callback with an additional function_name parameter. diff --git a/examples/foundational/14q-function-calling-qwen.py b/examples/foundational/14q-function-calling-qwen.py index 32c551b29..58d34a3e1 100644 --- a/examples/foundational/14q-function-calling-qwen.py +++ b/examples/foundational/14q-function-calling-qwen.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.qwen.llm import QwenLLMService @@ -64,7 +64,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = QwenLLMService( diff --git a/examples/foundational/14r-function-calling-aws.py b/examples/foundational/14r-function-calling-aws.py index 1ce5c4220..9e8e9836f 100644 --- a/examples/foundational/14r-function-calling-aws.py +++ b/examples/foundational/14r-function-calling-aws.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.aws.llm import AWSBedrockLLMService +from pipecat.services.aws.llm import AWSBedrockLLMService, AWSBedrockLLMSettings from pipecat.services.aws.stt import AWSTranscribeSTTService -from pipecat.services.aws.tts import AWSPollyTTSService +from pipecat.services.aws.tts import AWSPollyTTSService, AWSPollyTTSSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -66,14 +66,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = AWSPollyTTSService( region="us-west-2", # only specific regions support generative TTS - voice_id="Joanna", - params=AWSPollyTTSService.InputParams(engine="generative", rate="1.1"), + settings=AWSPollyTTSSettings( + voice_id="Joanna", + engine="generative", + rate="1.1", + ), ) llm = AWSBedrockLLMService( aws_region="us-west-2", - model="us.anthropic.claude-haiku-4-5-20251001-v1:0", - params=AWSBedrockLLMService.InputParams(temperature=0.8), + settings=AWSBedrockLLMSettings( + model="us.anthropic.claude-haiku-4-5-20251001-v1:0", + temperature=0.8, + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/14s-function-calling-sambanova.py b/examples/foundational/14s-function-calling-sambanova.py index 1548b2aa1..8cb007691 100644 --- a/examples/foundational/14s-function-calling-sambanova.py +++ b/examples/foundational/14s-function-calling-sambanova.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.services.sambanova.llm import SambaNovaLLMService from pipecat.services.sambanova.stt import SambaNovaSTTService @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = SambaNovaLLMService( diff --git a/examples/foundational/14t-function-calling-direct.py b/examples/foundational/14t-function-calling-direct.py index 31efb7ac9..b2912b91a 100644 --- a/examples/foundational/14t-function-calling-direct.py +++ b/examples/foundational/14t-function-calling-direct.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -80,7 +80,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/14u-function-calling-ollama.py b/examples/foundational/14u-function-calling-ollama.py index b7c65dedf..53b81402d 100644 --- a/examples/foundational/14u-function-calling-ollama.py +++ b/examples/foundational/14u-function-calling-ollama.py @@ -24,10 +24,10 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams -from pipecat.services.ollama.llm import OLLamaLLMService +from pipecat.services.ollama.llm import OLLamaLLMService, OLLamaLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -68,11 +68,15 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OLLamaLLMService( - model="llama3.2", + settings=OLLamaLLMSettings( + model="llama3.2", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) # Update to the model you're running locally diff --git a/examples/foundational/14v-function-calling-openai.py b/examples/foundational/14v-function-calling-openai.py index 920275975..77bacc091 100644 --- a/examples/foundational/14v-function-calling-openai.py +++ b/examples/foundational/14v-function-calling-openai.py @@ -25,8 +25,8 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService -from pipecat.services.openai.stt import OpenAISTTService -from pipecat.services.openai.tts import OpenAITTSService +from pipecat.services.openai.stt import OpenAISTTService, OpenAISTTSettings +from pipecat.services.openai.tts import OpenAITTSService, OpenAITTSSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -65,15 +65,17 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = OpenAISTTService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o-transcribe", - prompt="Expect words related weather, such as temperature and conditions. And restaurant names.", + settings=OpenAISTTSettings( + model="gpt-4o-transcribe", + prompt="Expect words related weather, such as temperature and conditions. And restaurant names.", + ), ) - # voice choices: ash, ballad, or any other voice available in the OpenAI TTS API - # see https://www.openai.fm/ tts = OpenAITTSService( api_key=os.getenv("OPENAI_API_KEY"), - voice="ballad", + settings=OpenAITTSSettings( + voice="ballad", + ), instructions="Please speak clearly and at a moderate pace.", ) diff --git a/examples/foundational/14w-function-calling-mistral.py b/examples/foundational/14w-function-calling-mistral.py index e17d31f72..fa809414b 100644 --- a/examples/foundational/14w-function-calling-mistral.py +++ b/examples/foundational/14w-function-calling-mistral.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.mistral.llm import MistralLLMService @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = MistralLLMService( diff --git a/examples/foundational/14x-function-calling-openpipe.py b/examples/foundational/14x-function-calling-openpipe.py index 8a71a83d7..61382c435 100644 --- a/examples/foundational/14x-function-calling-openpipe.py +++ b/examples/foundational/14x-function-calling-openpipe.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openpipe.llm import OpenPipeLLMService @@ -68,7 +68,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) timestamp = int(time.time()) diff --git a/examples/foundational/15-switch-voices.py b/examples/foundational/15-switch-voices.py index 4478c067b..f749a03c7 100644 --- a/examples/foundational/15-switch-voices.py +++ b/examples/foundational/15-switch-voices.py @@ -26,7 +26,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.filters.function_filter import FunctionFilter from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -43,17 +43,23 @@ class SwitchVoices(ParallelPipeline): news_lady = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="bf991597-6c13-47e4-8411-91ec2de5c466", # Newslady + settings=CartesiaTTSSettings( + voice="bf991597-6c13-47e4-8411-91ec2de5c466", # Newslady + ), ) british_lady = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) barbershop_man = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="a0e99841-438c-4a64-b679-ae501e7d6091", # Barbershop Man + settings=CartesiaTTSSettings( + voice="a0e99841-438c-4a64-b679-ae501e7d6091", # Barbershop Man + ), ) super().__init__( diff --git a/examples/foundational/15a-switch-languages.py b/examples/foundational/15a-switch-languages.py index 3ad897077..dad7e0ee3 100644 --- a/examples/foundational/15a-switch-languages.py +++ b/examples/foundational/15a-switch-languages.py @@ -27,7 +27,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.filters.function_filter import FunctionFilter from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -44,12 +44,16 @@ class SwitchLanguage(ParallelPipeline): english_tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) spanish_tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="d4db5fb9-f44b-4bd1-85fa-192e0f0d75f9", # Spanish-speaking Lady + settings=CartesiaTTSSettings( + voice="d4db5fb9-f44b-4bd1-85fa-192e0f0d75f9", # Spanish-speaking Lady + ), ) super().__init__( diff --git a/examples/foundational/16-gpu-container-local-bot.py b/examples/foundational/16-gpu-container-local-bot.py index 8367e1044..cf02b37ce 100644 --- a/examples/foundational/16-gpu-container-local-bot.py +++ b/examples/foundational/16-gpu-container-local-bot.py @@ -23,8 +23,8 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import ( DailyOutputTransportMessageFrame, @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = DeepgramTTSService( api_key=os.getenv("DEEPGRAM_API_KEY"), - voice="aura-asteria-en", + settings=DeepgramTTSSettings( + voice="aura-asteria-en", + ), base_url="http://0.0.0.0:8080", ) @@ -68,7 +70,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # To use OpenAI # api_key=os.getenv("OPENAI_API_KEY"), # Or, to use a local vLLM (or similar) api server - model="meta-llama/Meta-Llama-3-8B-Instruct", + settings=OpenAILLMSettings( + model="meta-llama/Meta-Llama-3-8B-Instruct", + ), base_url="http://0.0.0.0:8000/v1", system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/17-detect-user-idle.py b/examples/foundational/17-detect-user-idle.py index 217162ea8..9da863bc9 100644 --- a/examples/foundational/17-detect-user-idle.py +++ b/examples/foundational/17-detect-user-idle.py @@ -32,7 +32,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameDirection from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -115,7 +115,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/19b-openai-realtime-beta-text.py b/examples/foundational/19b-openai-realtime-beta-text.py index 83e1563a0..7a4ad3469 100644 --- a/examples/foundational/19b-openai-realtime-beta-text.py +++ b/examples/foundational/19b-openai-realtime-beta-text.py @@ -21,7 +21,7 @@ from pipecat.pipeline.task import PipelineParams, PipelineTask from pipecat.processors.aggregators.openai_llm_context import OpenAILLMContext from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai_realtime_beta import ( InputAudioNoiseReduction, @@ -147,7 +147,9 @@ Remember, your responses should be short. Just one or two sentences, usually. Re tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # you can either register a single function for all function calls, or specific functions diff --git a/examples/foundational/19b-openai-realtime-text.py b/examples/foundational/19b-openai-realtime-text.py index 38731d72a..98dc81c3b 100644 --- a/examples/foundational/19b-openai-realtime-text.py +++ b/examples/foundational/19b-openai-realtime-text.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_context import LLMContext from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.realtime.events import ( AudioConfiguration, @@ -154,7 +154,9 @@ Remember, your responses should be short. Just one or two sentences, usually. Re tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # you can either register a single function for all function calls, or specific functions diff --git a/examples/foundational/20a-persistent-context-openai.py b/examples/foundational/20a-persistent-context-openai.py index be40add52..acdcefb92 100644 --- a/examples/foundational/20a-persistent-context-openai.py +++ b/examples/foundational/20a-persistent-context-openai.py @@ -26,7 +26,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -180,7 +180,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) diff --git a/examples/foundational/20c-persistent-context-anthropic.py b/examples/foundational/20c-persistent-context-anthropic.py index d99f4debf..5f2a3f317 100644 --- a/examples/foundational/20c-persistent-context-anthropic.py +++ b/examples/foundational/20c-persistent-context-anthropic.py @@ -27,7 +27,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -189,12 +189,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), model="claude-3-5-sonnet-latest" - ) + llm = AnthropicLLMService(api_key=os.getenv("ANTHROPIC_API_KEY")) # you can either register a single function for all function calls, or specific functions # llm.register_function(None, fetch_weather_from_api) diff --git a/examples/foundational/20d-persistent-context-gemini.py b/examples/foundational/20d-persistent-context-gemini.py index 3bcd3c106..ca5186532 100644 --- a/examples/foundational/20d-persistent-context-gemini.py +++ b/examples/foundational/20d-persistent-context-gemini.py @@ -31,7 +31,7 @@ from pipecat.runner.utils import ( get_transport_client_id, maybe_capture_participant_camera, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.llm_service import FunctionCallParams @@ -257,7 +257,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY")) diff --git a/examples/foundational/21-tavus-transport.py b/examples/foundational/21-tavus-transport.py index b16ebbf38..06d904c21 100644 --- a/examples/foundational/21-tavus-transport.py +++ b/examples/foundational/21-tavus-transport.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMContextAggregatorPair, LLMUserAggregatorParams, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.transports.tavus.transport import TavusParams, TavusTransport @@ -51,7 +51,9 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="a167e0f3-df7e-4d52-a9c3-f949145efdab", + settings=CartesiaTTSSettings( + voice="a167e0f3-df7e-4d52-a9c3-f949145efdab", + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/21a-tavus-video-service.py b/examples/foundational/21a-tavus-video-service.py index 7e32579b0..c756a7821 100644 --- a/examples/foundational/21a-tavus-video-service.py +++ b/examples/foundational/21a-tavus-video-service.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.tavus.video import TavusVideoService @@ -61,7 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="a167e0f3-df7e-4d52-a9c3-f949145efdab", + settings=CartesiaTTSSettings( + voice="a167e0f3-df7e-4d52-a9c3-f949145efdab", + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/22-filter-incomplete-turns.py b/examples/foundational/22-filter-incomplete-turns.py index b7d094d1e..876999bcd 100644 --- a/examples/foundational/22-filter-incomplete-turns.py +++ b/examples/foundational/22-filter-incomplete-turns.py @@ -35,7 +35,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -68,21 +68,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) + llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - messages = [ - { - "role": "system", - "content": f"""You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.""", - } - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams( @@ -128,9 +126,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - messages.append( + context.add_message( { - "role": "system", + "role": "user", "content": "Please introduce yourself to the user, asking them a question that will require a complete response. To start, say 'Let me start with a fun one. If you could travel anywhere in the world right now, where would you go and why?'", } ) diff --git a/examples/foundational/23-bot-background-sound.py b/examples/foundational/23-bot-background-sound.py index a57e8f446..a88ebc9bc 100644 --- a/examples/foundational/23-bot-background-sound.py +++ b/examples/foundational/23-bot-background-sound.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -75,7 +75,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/24-user-mute-strategy.py b/examples/foundational/24-user-mute-strategy.py index 36b537e6a..d4276f04a 100644 --- a/examples/foundational/24-user-mute-strategy.py +++ b/examples/foundational/24-user-mute-strategy.py @@ -26,7 +26,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -71,7 +71,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - tts = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY"), voice="aura-helios-en") + tts = DeepgramTTSService( + api_key=os.getenv("DEEPGRAM_API_KEY"), + settings=DeepgramTTSSettings( + voice="aura-2-helena-en", + ), + ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), diff --git a/examples/foundational/25-google-audio-in.py b/examples/foundational/25-google-audio-in.py index 40903e1d5..a278ea4b3 100644 --- a/examples/foundational/25-google-audio-in.py +++ b/examples/foundational/25-google-audio-in.py @@ -32,8 +32,8 @@ from pipecat.processors.aggregators.llm_response_universal import LLMContextAggr from pipecat.processors.frame_processor import FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -290,13 +290,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) conversation_llm = GoogleLLMService( name="Conversation", - model="gemini-2.0-flash-001", - # model="gemini-exp-1121", + settings=GoogleLLMSettings( + model="gemini-2.5-flash", + ), api_key=os.getenv("GOOGLE_API_KEY"), # we can give the GoogleLLMService a system instruction to use directly # in the GenerativeModel constructor. Let's do that rather than put @@ -306,8 +309,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): input_transcription_llm = GoogleLLMService( name="Transcription", - model="gemini-2.0-flash-001", - # model="gemini-exp-1121", + settings=GoogleLLMSettings( + model="gemini-2.5-flash", + ), api_key=os.getenv("GOOGLE_API_KEY"), system_instruction=transcriber_system_message, ) diff --git a/examples/foundational/26d-gemini-live-text.py b/examples/foundational/26d-gemini-live-text.py index 1b3845fa3..eebe9874d 100644 --- a/examples/foundational/26d-gemini-live-text.py +++ b/examples/foundational/26d-gemini-live-text.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.google.gemini_live.llm import ( GeminiLiveLLMService, GeminiModalities, diff --git a/examples/foundational/27-simli-layer.py b/examples/foundational/27-simli-layer.py index fb469fbe1..05d0649d6 100644 --- a/examples/foundational/27-simli-layer.py +++ b/examples/foundational/27-simli-layer.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.services.simli.video import SimliVideoService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", + ), ) simli_ai = SimliVideoService( @@ -70,7 +72,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o-mini", + settings=OpenAILLMSettings( + model="gpt-4o-mini", + ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/28-user-assistant-turns.py b/examples/foundational/28-user-assistant-turns.py index 9dd1fa2a1..d59ad3870 100644 --- a/examples/foundational/28-user-assistant-turns.py +++ b/examples/foundational/28-user-assistant-turns.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -122,7 +122,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/29-turn-tracking-observer.py b/examples/foundational/29-turn-tracking-observer.py index 9ba22dfda..0dd164bd0 100644 --- a/examples/foundational/29-turn-tracking-observer.py +++ b/examples/foundational/29-turn-tracking-observer.py @@ -27,7 +27,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -73,7 +73,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/30-observer.py b/examples/foundational/30-observer.py index 4616e0e03..5ee0bdaed 100644 --- a/examples/foundational/30-observer.py +++ b/examples/foundational/30-observer.py @@ -34,7 +34,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.frame_processor import FrameDirection from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_input import BaseInputTransport @@ -104,7 +104,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/32-gemini-grounding-metadata.py b/examples/foundational/32-gemini-grounding-metadata.py index 19844b1fa..2977e19bc 100644 --- a/examples/foundational/32-gemini-grounding-metadata.py +++ b/examples/foundational/32-gemini-grounding-metadata.py @@ -25,7 +25,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService, LLMSearchResponseFrame from pipecat.services.llm_service import LLMService @@ -99,7 +99,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # Initialize the Gemini Multimodal Live model diff --git a/examples/foundational/33-gemini-rag.py b/examples/foundational/33-gemini-rag.py index ae95ce117..c34a9c83e 100644 --- a/examples/foundational/33-gemini-rag.py +++ b/examples/foundational/33-gemini-rag.py @@ -69,9 +69,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -183,11 +183,24 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="f9836c6e-a0bd-460e-9d3c-f7299fa60f94", # Southern Lady + settings=CartesiaTTSSettings( + voice="f9836c6e-a0bd-460e-9d3c-f7299fa60f94", # Southern Lady + ), ) + system_prompt = """\ +You are a helpful assistant who converses with a user and answers questions. + +You have access to the tool, query_knowledge_base, that allows you to query the knowledge base for the answer to the user's question. + +Your response will be turned into speech so use only simple words and punctuation. +""" + llm = GoogleLLMService( - model=VOICE_MODEL, + settings=GoogleLLMSettings( + model=VOICE_MODEL, + ), + system_instruction=system_prompt, api_key=os.getenv("GOOGLE_API_KEY"), ) llm.register_function("query_knowledge_base", query_knowledge_base) @@ -205,15 +218,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tools = ToolsSchema(standard_tools=[query_function]) - system_prompt = """\ -You are a helpful assistant who converses with a user and answers questions. - -You have access to the tool, query_knowledge_base, that allows you to query the knowledge base for the answer to the user's question. - -Your response will be turned into speech so use only simple words and punctuation. -""" messages = [ - {"role": "system", "content": system_prompt}, {"role": "user", "content": "Greet the user."}, ] diff --git a/examples/foundational/34-audio-recording.py b/examples/foundational/34-audio-recording.py index 8435acbde..aa52c213a 100644 --- a/examples/foundational/34-audio-recording.py +++ b/examples/foundational/34-audio-recording.py @@ -63,7 +63,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.audio.audio_buffer_processor import AudioBufferProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -112,12 +112,13 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", + ), ) llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4", system_instruction="You are a helpful assistant demonstrating audio recording capabilities. Keep your responses brief and clear.", ) diff --git a/examples/foundational/35-pattern-pair-voice-switching.py b/examples/foundational/35-pattern-pair-voice-switching.py index cacc04459..c10e185b0 100644 --- a/examples/foundational/35-pattern-pair-voice-switching.py +++ b/examples/foundational/35-pattern-pair-voice-switching.py @@ -56,7 +56,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -129,13 +129,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Initialize TTS with narrator voice as default tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id=VOICE_IDS["narrator"], + settings=CartesiaTTSSettings( + voice=VOICE_IDS["narrator"], + ), text_aggregator=pattern_aggregator, ) - # Initialize LLM - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) - # System prompt for storytelling with voice switching system_prompt = """You are an engaging storyteller that uses different voices to bring stories to life. @@ -184,15 +183,13 @@ FOLLOW THESE RULES: Remember: Use narrator voice for EVERYTHING except the actual quoted dialogue.""" - # Set up LLM context - messages = [ - { - "role": "system", - "content": system_prompt, - }, - ] + # Initialize LLM + llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY"), + system_instruction=system_prompt, + ) - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/36-user-email-gathering.py b/examples/foundational/36-user-email-gathering.py index 95450c695..9c4bdd4ac 100644 --- a/examples/foundational/36-user-email-gathering.py +++ b/examples/foundational/36-user-email-gathering.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # (see https://docs.cartesia.ai/build-with-sonic/formatting-text-for-sonic/spelling-out-input-text) tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # Rime offers a function `spell()` that we can use to ask the user diff --git a/examples/foundational/37-mem0.py b/examples/foundational/37-mem0.py index bfc651f3a..e02d86915 100644 --- a/examples/foundational/37-mem0.py +++ b/examples/foundational/37-mem0.py @@ -60,9 +60,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.elevenlabs.tts import ElevenLabsTTSService +from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings from pipecat.services.mem0.memory import Mem0MemoryService -from pipecat.services.openai.llm import OpenAILLMService +from pipecat.services.openai.llm import OpenAILLMService, OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -166,7 +166,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Initialize text-to-speech service tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY"), - voice_id="pNInz6obpgDQGcFmaJgB", + settings=ElevenLabsTTSSettings( + voice="pNInz6obpgDQGcFmaJgB", + ), ) # ===================================================================== @@ -223,7 +225,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Initialize LLM service llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), - model="gpt-4o-mini", + settings=OpenAILLMSettings( + model="gpt-4o-mini", + ), system_instruction="""You are a personal assistant. You can remember things about the person you are talking to. Some Guidelines: - Make sure your responses are friendly yet short and concise. diff --git a/examples/foundational/38-smart-turn-fal.py b/examples/foundational/38-smart-turn-fal.py index fe8992784..384652b29 100644 --- a/examples/foundational/38-smart-turn-fal.py +++ b/examples/foundational/38-smart-turn-fal.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -61,7 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/38a-smart-turn-local-coreml.py b/examples/foundational/38a-smart-turn-local-coreml.py index 166fbbe12..01585982d 100644 --- a/examples/foundational/38a-smart-turn-local-coreml.py +++ b/examples/foundational/38a-smart-turn-local-coreml.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -76,7 +76,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/38b-smart-turn-local.py b/examples/foundational/38b-smart-turn-local.py index 962b608da..aceff9bc9 100644 --- a/examples/foundational/38b-smart-turn-local.py +++ b/examples/foundational/38b-smart-turn-local.py @@ -24,7 +24,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -58,7 +58,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/39-mcp-stdio.py b/examples/foundational/39-mcp-stdio.py index 2daf21626..0919e2fb0 100644 --- a/examples/foundational/39-mcp-stdio.py +++ b/examples/foundational/39-mcp-stdio.py @@ -36,7 +36,7 @@ from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.mcp_service import MCPClient from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -137,12 +137,25 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), model="claude-3-7-sonnet-latest" - ) + system = f""" + You are a helpful LLM in a WebRTC call. + Your goal is to demonstrate your capabilities in a succinct way. + You have access to tools to search the Rijksmuseum collection. + Offer, for example, to show a floral still life, use the `search_artwork` tool. + The tool may respond with a JSON object with an `artworks` array. Choose the art from that array. + Once the tool has responded, tell the user the title and use the `open_image_in_browser` tool. + Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. + Respond to what the user said in a creative and helpful way. + Don't overexplain what you are doing. + Just respond with short sentences when you are carrying out tool calls. + """ + + llm = AnthropicLLMService(api_key=os.getenv("ANTHROPIC_API_KEY"), system_instruction=system) try: mcp = MCPClient( @@ -169,22 +182,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.error(f"error registering tools") logger.exception("error trace:") - system = f""" - You are a helpful LLM in a WebRTC call. - Your goal is to demonstrate your capabilities in a succinct way. - You have access to tools to search the Rijksmuseum collection. - Offer, for example, to show a floral still life, use the `search_artwork` tool. - The tool may respond with a JSON object with an `artworks` array. Choose the art from that array. - Once the tool has responded, tell the user the title and use the `open_image_in_browser` tool. - Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. - Respond to what the user said in a creative and helpful way. - Don't overexplain what you are doing. - Just respond with short sentences when you are carrying out tool calls. - """ - - messages = [{"role": "system", "content": system}] - - context = LLMContext(messages, tools) + context = LLMContext(tools=tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/39a-mcp-streamable-http.py b/examples/foundational/39a-mcp-streamable-http.py index 2af2ba9cb..870556073 100644 --- a/examples/foundational/39a-mcp-streamable-http.py +++ b/examples/foundational/39a-mcp-streamable-http.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.mcp_service import MCPClient @@ -58,7 +58,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY"), model="gemini-2.0-flash") diff --git a/examples/foundational/39b-mcp-streamable-http-gemini-live.py b/examples/foundational/39b-mcp-streamable-http-gemini-live.py index c4c427bd8..8a0ea57fd 100644 --- a/examples/foundational/39b-mcp-streamable-http-gemini-live.py +++ b/examples/foundational/39b-mcp-streamable-http-gemini-live.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.gemini_live.llm import GeminiLiveLLMService from pipecat.services.mcp_service import MCPClient @@ -58,7 +58,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) try: diff --git a/examples/foundational/39c-multiple-mcp.py b/examples/foundational/39c-multiple-mcp.py index 5f662cdb8..dcda884ec 100644 --- a/examples/foundational/39c-multiple-mcp.py +++ b/examples/foundational/39c-multiple-mcp.py @@ -38,7 +38,7 @@ from pipecat.processors.frame_processor import FrameDirection, FrameProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.mcp_service import MCPClient from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -120,11 +120,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady - ) - - llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), model="claude-3-7-sonnet-latest" + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) system = f""" @@ -141,7 +139,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): Just respond with short sentences when you are carrying out tool calls. """ - messages = [{"role": "system", "content": system}] + llm = AnthropicLLMService(api_key=os.getenv("ANTHROPIC_API_KEY"), system_instruction=system) try: rijksmuseum_mcp = MCPClient( @@ -184,7 +182,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): all_standard_tools = rijksmuseum_tools.standard_tools + github_tools.standard_tools all_tools = ToolsSchema(standard_tools=all_standard_tools) - context = LLMContext(messages, all_tools) + context = LLMContext(tools=all_tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), diff --git a/examples/foundational/42-interruption-config.py b/examples/foundational/42-interruption-config.py index 4491f9ee0..f8add9019 100644 --- a/examples/foundational/42-interruption-config.py +++ b/examples/foundational/42-interruption-config.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/43-heygen-transport.py b/examples/foundational/43-heygen-transport.py index e38cb7b6e..5797aeb25 100644 --- a/examples/foundational/43-heygen-transport.py +++ b/examples/foundational/43-heygen-transport.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMContextAggregatorPair, LLMUserAggregatorParams, ) -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.heygen.api_liveavatar import LiveAvatarNewSessionRequest @@ -56,7 +56,9 @@ async def main(): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="00967b2f-88a6-4a31-8153-110a92134b9f", + settings=CartesiaTTSSettings( + voice="00967b2f-88a6-4a31-8153-110a92134b9f", + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/43a-heygen-video-service.py b/examples/foundational/43a-heygen-video-service.py index 2b23fe1f8..5be8f1caa 100644 --- a/examples/foundational/43a-heygen-video-service.py +++ b/examples/foundational/43a-heygen-video-service.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService from pipecat.services.heygen.api_liveavatar import LiveAvatarNewSessionRequest @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="00967b2f-88a6-4a31-8153-110a92134b9f", + settings=CartesiaTTSSettings( + voice="00967b2f-88a6-4a31-8153-110a92134b9f", + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/44-voicemail-detection.py b/examples/foundational/44-voicemail-detection.py index f7cf14f71..e46c59cc0 100644 --- a/examples/foundational/44-voicemail-detection.py +++ b/examples/foundational/44-voicemail-detection.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/45-before-and-after-events.py b/examples/foundational/45-before-and-after-events.py index 405af49f3..db71e283d 100644 --- a/examples/foundational/45-before-and-after-events.py +++ b/examples/foundational/45-before-and-after-events.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -67,7 +67,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/47-sentry-metrics.py b/examples/foundational/47-sentry-metrics.py index ef20745e4..f9983c46f 100644 --- a/examples/foundational/47-sentry-metrics.py +++ b/examples/foundational/47-sentry-metrics.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.metrics.sentry import SentryMetrics from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -66,7 +66,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), metrics=SentryMetrics(), ) diff --git a/examples/foundational/48-service-switcher.py b/examples/foundational/48-service-switcher.py index 4aaafa508..dd7d9ec82 100644 --- a/examples/foundational/48-service-switcher.py +++ b/examples/foundational/48-service-switcher.py @@ -27,9 +27,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.stt import CartesiaSTTService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.deepgram.tts import DeepgramTTSService +from pipecat.services.deepgram.tts import DeepgramTTSService, DeepgramTTSSettings from pipecat.services.google.llm import GoogleLLMService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -102,15 +102,24 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts_cartesia = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), + ) + tts_deepgram = DeepgramTTSService( + api_key=os.getenv("DEEPGRAM_API_KEY"), + settings=DeepgramTTSSettings( + voice="aura-2-helena-en", + ), ) - tts_deepgram = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY")) tts_switcher = ServiceSwitcher( services=[tts_cartesia, tts_deepgram], strategy_type=ServiceSwitcherStrategyManual ) - llm_openai = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) - llm_google = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY")) + system = "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way." + + llm_openai = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"), system_instruction=system) + llm_google = GoogleLLMService(api_key=os.getenv("GOOGLE_API_KEY"), system_instruction=system) llm_switcher = LLMSwitcher( llms=[llm_openai, llm_google], strategy_type=ServiceSwitcherStrategyManual ) @@ -119,15 +128,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Register a "direct" function llm_switcher.register_direct_function(get_restaurant_recommendation) - messages = [ - { - "role": "system", - "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", - }, - ] tools = ToolsSchema(standard_tools=[weather_function, get_restaurant_recommendation]) - context = LLMContext(messages, tools) + context = LLMContext(tools=tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), @@ -158,7 +161,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Please introduce yourself to the user."}) + context.add_message({"role": "user", "content": "Please introduce yourself to the user."}) await task.queue_frames([LLMRunFrame()]) await asyncio.sleep(15) print(f"Switching to {stt_deepgram}") diff --git a/examples/foundational/49a-thinking-anthropic.py b/examples/foundational/49a-thinking-anthropic.py index 28dd33565..fa84e7c6c 100644 --- a/examples/foundational/49a-thinking-anthropic.py +++ b/examples/foundational/49a-thinking-anthropic.py @@ -22,8 +22,12 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.anthropic.llm import ( + AnthropicLLMService, + AnthropicLLMSettings, + AnthropicThinkingConfig, +) +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -56,13 +60,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AnthropicLLMService( api_key=os.getenv("ANTHROPIC_API_KEY"), - params=AnthropicLLMService.InputParams( - thinking=AnthropicLLMService.ThinkingConfig(type="enabled", budget_tokens=2048) + settings=AnthropicLLMSettings( + thinking=AnthropicThinkingConfig( + type="enabled", + budget_tokens=2048, + ), ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/49b-thinking-google.py b/examples/foundational/49b-thinking-google.py index 32677bcbb..0fb0a30f0 100644 --- a/examples/foundational/49b-thinking-google.py +++ b/examples/foundational/49b-thinking-google.py @@ -22,9 +22,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings, GoogleThinkingConfig from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams @@ -56,18 +56,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), # model="gemini-3-pro-preview", # A more powerful reasoning model, but slower - params=GoogleLLMService.InputParams( - thinking=GoogleLLMService.ThinkingConfig( - # thinking_level="low", # Use this field instead of thinking_budget for Gemini 3 Pro. Defaults to "high". + settings=GoogleLLMSettings( + thinking=GoogleThinkingConfig( thinking_budget=-1, # Dynamic thinking include_thoughts=True, - ) + ), ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/49c-thinking-functions-anthropic.py b/examples/foundational/49c-thinking-functions-anthropic.py index b070871b1..4fb66470d 100644 --- a/examples/foundational/49c-thinking-functions-anthropic.py +++ b/examples/foundational/49c-thinking-functions-anthropic.py @@ -23,8 +23,12 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.anthropic.llm import AnthropicLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.anthropic.llm import ( + AnthropicLLMService, + AnthropicLLMSettings, + AnthropicThinkingConfig, +) +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -77,13 +81,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AnthropicLLMService( api_key=os.getenv("ANTHROPIC_API_KEY"), - params=AnthropicLLMService.InputParams( - thinking=AnthropicLLMService.ThinkingConfig(type="enabled", budget_tokens=2048) + settings=AnthropicLLMSettings( + thinking=AnthropicThinkingConfig( + type="enabled", + budget_tokens=2048, + ), ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/49d-thinking-functions-google.py b/examples/foundational/49d-thinking-functions-google.py index 9b5a333de..3963fc387 100644 --- a/examples/foundational/49d-thinking-functions-google.py +++ b/examples/foundational/49d-thinking-functions-google.py @@ -23,9 +23,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google.llm import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings, GoogleThinkingConfig from pipecat.services.llm_service import FunctionCallParams from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -77,18 +77,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), # model="gemini-3-pro-preview", # A more powerful reasoning model, but slower - params=GoogleLLMService.InputParams( - thinking=GoogleLLMService.ThinkingConfig( - # thinking_level="low", # Use this field instead of thinking_budget for Gemini 3 Pro. Defaults to "high". + settings=GoogleLLMSettings( + thinking=GoogleThinkingConfig( thinking_budget=-1, # Dynamic thinking include_thoughts=True, - ) + ), ), system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", ) diff --git a/examples/foundational/52-live-translation.py b/examples/foundational/52-live-translation.py index 6ab0bac18..15598667f 100644 --- a/examples/foundational/52-live-translation.py +++ b/examples/foundational/52-live-translation.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -59,7 +59,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="d4db5fb9-f44b-4bd1-85fa-192e0f0d75f9", # Spanish-speaking Lady + settings=CartesiaTTSSettings( + voice="d4db5fb9-f44b-4bd1-85fa-192e0f0d75f9", # Spanish-speaking Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/53-concurrent-llm-evaluation.py b/examples/foundational/53-concurrent-llm-evaluation.py index 9fb44a44f..a93ca2ada 100644 --- a/examples/foundational/53-concurrent-llm-evaluation.py +++ b/examples/foundational/53-concurrent-llm-evaluation.py @@ -24,9 +24,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.audio.vad_processor import VADProcessor from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.groq.llm import GroqLLMService +from pipecat.services.groq.llm import GroqLLMService, GroqLLMSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -62,31 +62,24 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - openai_llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) - - openai_messages = [ - { - "role": "system", - "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", - }, - ] + openai_llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) groq_llm = GroqLLMService( - api_key=os.getenv("GROQ_API_KEY"), model="meta-llama/llama-4-maverick-17b-128e-instruct" + api_key=os.getenv("GROQ_API_KEY"), + settings=GroqLLMSettings(model="meta-llama/llama-4-maverick-17b-128e-instruct"), + system_instruction="You are a very helpful assistant. Your goal is to demonstrate your capabilities in detail in a creative and helpful way.", ) - groq_messages = [ - { - "role": "system", - "content": "You are a very helpful assistant. Your goal is to demonstrate your capabilities in detail in a creative and helpful way.", - }, - ] - - openai_context = LLMContext(openai_messages) - groq_context = LLMContext(groq_messages) + openai_context = LLMContext() + groq_context = LLMContext() # We use an external VADProcessor because the UserTurnProcessor is shared # across multiple parallel aggregators. The VADProcessor emits @@ -147,11 +140,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info(f"Client connected") # Kick off the conversation. - openai_messages.append( - {"role": "system", "content": "Please introduce yourself to the user."} + openai_context.add_message( + {"role": "user", "content": "Please introduce yourself to the user."} ) - groq_messages.append( - {"role": "system", "content": "Please introduce yourself to the user."} + groq_context.add_message( + {"role": "user", "content": "Please introduce yourself to the user."} ) await task.queue_frames([LLMRunFrame()]) diff --git a/examples/foundational/53-concurrent-llm-rtvi-ignored-sources.py b/examples/foundational/53-concurrent-llm-rtvi-ignored-sources.py index b16f8831f..f449269e9 100644 --- a/examples/foundational/53-concurrent-llm-rtvi-ignored-sources.py +++ b/examples/foundational/53-concurrent-llm-rtvi-ignored-sources.py @@ -31,7 +31,7 @@ from pipecat.processors.audio.vad_processor import VADProcessor from pipecat.processors.frameworks.rtvi import RTVIObserverParams from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -67,40 +67,27 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) # Main LLM — drives the conversation. Its RTVI events reach the client. - main_llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) - - main_messages = [ - { - "role": "system", - "content": "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", - }, - ] + main_llm = OpenAILLMService( + api_key=os.getenv("OPENAI_API_KEY"), + system_instruction="You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your capabilities in a succinct way. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Respond to what the user said in a creative and helpful way.", + ) # Evaluator LLM — silently grades the user's message in the background. # Its RTVI events will be suppressed so the client is unaware of this branch. evaluator_llm = OpenAILLMService( api_key=os.getenv("OPENAI_API_KEY"), name="EvaluatorLLM", + system_instruction="You are a silent quality evaluator. When given a user message, respond with a single JSON object: {'score': <1-5>, 'reason': ''}. Do not respond conversationally.", ) - evaluator_messages = [ - { - "role": "system", - "content": ( - "You are a silent quality evaluator. When given a user message, " - "respond with a single JSON object: " - '{"score": <1-5>, "reason": ""}. ' - "Do not respond conversationally." - ), - }, - ] - - main_context = LLMContext(main_messages) - evaluator_context = LLMContext(evaluator_messages) + main_context = LLMContext() + evaluator_context = LLMContext() # We use an external VADProcessor because the UserTurnProcessor is shared # across multiple parallel aggregators. The VADProcessor emits @@ -163,10 +150,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): @transport.event_handler("on_client_connected") async def on_client_connected(transport, client): logger.info("Client connected") - main_messages.append( - {"role": "system", "content": "Please introduce yourself to the user."} + main_context.add_message( + {"role": "user", "content": "Please introduce yourself to the user."} + ) + evaluator_context.add_message( + {"role": "user", "content": "Ready to evaluate user messages."} ) - evaluator_messages.append({"role": "system", "content": "Ready to evaluate user messages."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/54-context-summarization-openai.py b/examples/foundational/54-context-summarization-openai.py index 25ea496c3..8c7c38d62 100644 --- a/examples/foundational/54-context-summarization-openai.py +++ b/examples/foundational/54-context-summarization-openai.py @@ -34,7 +34,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -81,7 +81,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/54a-context-summarization-google.py b/examples/foundational/54a-context-summarization-google.py index c79e96c3d..21e2ef459 100644 --- a/examples/foundational/54a-context-summarization-google.py +++ b/examples/foundational/54a-context-summarization-google.py @@ -34,7 +34,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google import GoogleLLMService from pipecat.services.llm_service import FunctionCallParams @@ -81,7 +81,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/54b-context-summarization-manual-openai.py b/examples/foundational/54b-context-summarization-manual-openai.py index c1ff83ef0..0fd2c0bd7 100644 --- a/examples/foundational/54b-context-summarization-manual-openai.py +++ b/examples/foundational/54b-context-summarization-manual-openai.py @@ -34,7 +34,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService @@ -78,10 +78,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) + system_prompt = """You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your + capabilities in a succinct way. Your output will be spoken aloud, so avoid + special characters that can't easily be spoken, such as emojis or bullet points. + Respond to what the user said in a creative and helpful way. + If the user asks you to summarize the conversation, call the + summarize_conversation function. After summarization, briefly acknowledge + that the conversation history has been compressed. + """ + + llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"), system_instruction=system_prompt) llm.register_function("summarize_conversation", summarize_conversation) @@ -97,22 +108,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tools = ToolsSchema(standard_tools=[summarize_function]) - messages = [ - { - "role": "system", - "content": ( - "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your " - "capabilities in a succinct way. Your output will be spoken aloud, so avoid " - "special characters that can't easily be spoken, such as emojis or bullet points. " - "Respond to what the user said in a creative and helpful way. " - "If the user asks you to summarize the conversation, call the " - "summarize_conversation function. After summarization, briefly acknowledge " - "that the conversation history has been compressed." - ), - }, - ] - - context = LLMContext(messages, tools=tools) + context = LLMContext(tools=tools) # Automatic summarization is NOT enabled here (enable_auto_context_summarization # defaults to False). The summarizer is still created internally so that @@ -147,7 +143,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info("Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Please introduce yourself to the user."}) + context.add_message({"role": "user", "content": "Please introduce yourself to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/54c-context-summarization-dedicated-llm.py b/examples/foundational/54c-context-summarization-dedicated-llm.py index 1dce3890f..ce0f7658f 100644 --- a/examples/foundational/54c-context-summarization-dedicated-llm.py +++ b/examples/foundational/54c-context-summarization-dedicated-llm.py @@ -36,9 +36,9 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.google import GoogleLLMService +from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -93,16 +93,29 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) + system_prompt = """You are a helpful LLM in a WebRTC call. Your goal is to demonstrate your + capabilities in a succinct way. Your output will be spoken aloud, so avoid + special characters that can't easily be spoken, such as emojis or bullet points. + Respond to what the user said in a creative and helpful way. + You have access to tools to get the current weather - use them when relevant. + When you see a block, it contains a compressed summary + of earlier conversation. Use it as reference but don't mention it to the user. + """ + # Primary LLM for conversation (could be any provider) - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) + llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY"), system_instruction=system_prompt) # Dedicated cheap/fast LLM for summarization only summarization_llm = GoogleLLMService( api_key=os.getenv("GOOGLE_API_KEY"), - model="gemini-2.5-flash", + settings=GoogleLLMSettings( + model="gemini-2.5-flash", + ), ) # Register tool functions @@ -126,22 +139,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tools = ToolsSchema(standard_tools=[weather_function]) - messages = [ - { - "role": "system", - "content": ( - "You are a helpful LLM in a WebRTC call. Your goal is to demonstrate " - "your capabilities in a succinct way. Your output will be spoken aloud, " - "so avoid special characters that can't easily be spoken. Respond to what " - "the user said in a creative and helpful way. You have access to tools to " - "get the current weather - use them when relevant.\n\n" - "When you see a block, it contains a compressed summary " - "of earlier conversation. Use it as reference but don't mention it to the user." - ), - }, - ] - - context = LLMContext(messages, tools=tools) + context = LLMContext(tools=tools) # Create aggregators with custom summarization user_aggregator, assistant_aggregator = LLMContextAggregatorPair( @@ -211,7 +209,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async def on_client_connected(transport, client): logger.info("Client connected") # Kick off the conversation. - messages.append({"role": "system", "content": "Please introduce yourself to the user."}) + context.add_message({"role": "user", "content": "Please introduce yourself to the user."}) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/foundational/55a-update-settings-deepgram-flux-stt.py b/examples/foundational/55a-update-settings-deepgram-flux-stt.py index ef58fe8fb..0a507aaed 100644 --- a/examples/foundational/55a-update-settings-deepgram-flux-stt.py +++ b/examples/foundational/55a-update-settings-deepgram-flux-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.flux.stt import DeepgramFluxSTTService, DeepgramFluxSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55a-update-settings-deepgram-sagemaker-stt.py b/examples/foundational/55a-update-settings-deepgram-sagemaker-stt.py index 489ea1276..b6f2142bc 100644 --- a/examples/foundational/55a-update-settings-deepgram-sagemaker-stt.py +++ b/examples/foundational/55a-update-settings-deepgram-sagemaker-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.sagemaker.stt import ( DeepgramSageMakerSTTService, DeepgramSageMakerSTTSettings, @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55a-update-settings-deepgram-stt.py b/examples/foundational/55a-update-settings-deepgram-stt.py index b0521bb19..b914d8085 100644 --- a/examples/foundational/55a-update-settings-deepgram-stt.py +++ b/examples/foundational/55a-update-settings-deepgram-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService, DeepgramSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55b-update-settings-azure-stt.py b/examples/foundational/55b-update-settings-azure-stt.py index 1d3b3fcee..c54b1a0d8 100644 --- a/examples/foundational/55b-update-settings-azure-stt.py +++ b/examples/foundational/55b-update-settings-azure-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.azure.stt import AzureSTTService, AzureSTTSettings -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -58,7 +58,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55c-update-settings-google-stt.py b/examples/foundational/55c-update-settings-google-stt.py index 2956b8047..23b312f5f 100644 --- a/examples/foundational/55c-update-settings-google-stt.py +++ b/examples/foundational/55c-update-settings-google-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.google.stt import GoogleSTTService, GoogleSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55d-update-settings-assemblyai-stt.py b/examples/foundational/55d-update-settings-assemblyai-stt.py index f8c366a44..e6d10d04f 100644 --- a/examples/foundational/55d-update-settings-assemblyai-stt.py +++ b/examples/foundational/55d-update-settings-assemblyai-stt.py @@ -24,7 +24,7 @@ from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.assemblyai.models import AssemblyAIConnectionParams from pipecat.services.assemblyai.stt import AssemblyAISTTService, AssemblyAISTTSettings -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55e-update-settings-gladia-stt.py b/examples/foundational/55e-update-settings-gladia-stt.py index 5b8283f72..6cc3fc92a 100644 --- a/examples/foundational/55e-update-settings-gladia-stt.py +++ b/examples/foundational/55e-update-settings-gladia-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.gladia.stt import GladiaSTTService, GladiaSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55f-update-settings-elevenlabs-realtime-stt.py b/examples/foundational/55f-update-settings-elevenlabs-realtime-stt.py index 8d2c17778..ef1e44b61 100644 --- a/examples/foundational/55f-update-settings-elevenlabs-realtime-stt.py +++ b/examples/foundational/55f-update-settings-elevenlabs-realtime-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.elevenlabs.stt import ( ElevenLabsRealtimeSTTService, ElevenLabsRealtimeSTTSettings, @@ -58,7 +58,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55g-update-settings-elevenlabs-stt.py b/examples/foundational/55g-update-settings-elevenlabs-stt.py index 0395f273d..c3fb9eac9 100644 --- a/examples/foundational/55g-update-settings-elevenlabs-stt.py +++ b/examples/foundational/55g-update-settings-elevenlabs-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.elevenlabs.stt import ElevenLabsSTTService, ElevenLabsSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language @@ -60,7 +60,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55h-update-settings-speechmatics-stt.py b/examples/foundational/55h-update-settings-speechmatics-stt.py index ba775199a..1471f7ef2 100644 --- a/examples/foundational/55h-update-settings-speechmatics-stt.py +++ b/examples/foundational/55h-update-settings-speechmatics-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.speechmatics.stt import SpeechmaticsSTTService, SpeechmaticsSTTSettings from pipecat.transcriptions.language import Language @@ -62,7 +62,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55i-update-settings-whisper-api-stt.py b/examples/foundational/55i-update-settings-whisper-api-stt.py index 962a70485..6b957a0be 100644 --- a/examples/foundational/55i-update-settings-whisper-api-stt.py +++ b/examples/foundational/55i-update-settings-whisper-api-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.openai.stt import OpenAISTTService from pipecat.services.whisper.base_stt import BaseWhisperSTTSettings @@ -61,7 +61,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55j-update-settings-sarvam-stt.py b/examples/foundational/55j-update-settings-sarvam-stt.py index 58f0f80c7..57ebccab5 100644 --- a/examples/foundational/55j-update-settings-sarvam-stt.py +++ b/examples/foundational/55j-update-settings-sarvam-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.sarvam.stt import SarvamSTTService, SarvamSTTSettings from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55k-update-settings-soniox-stt.py b/examples/foundational/55k-update-settings-soniox-stt.py index b31a0e708..ac339e3c1 100644 --- a/examples/foundational/55k-update-settings-soniox-stt.py +++ b/examples/foundational/55k-update-settings-soniox-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.soniox.stt import SonioxSTTService, SonioxSTTSettings from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55l-update-settings-aws-transcribe-stt.py b/examples/foundational/55l-update-settings-aws-transcribe-stt.py index 910bc66b4..5594f21d9 100644 --- a/examples/foundational/55l-update-settings-aws-transcribe-stt.py +++ b/examples/foundational/55l-update-settings-aws-transcribe-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.aws.stt import AWSTranscribeSTTService, AWSTranscribeSTTSettings -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55m-update-settings-cartesia-stt.py b/examples/foundational/55m-update-settings-cartesia-stt.py index 4956d8d75..f1a984d9b 100644 --- a/examples/foundational/55m-update-settings-cartesia-stt.py +++ b/examples/foundational/55m-update-settings-cartesia-stt.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.cartesia.stt import CartesiaSTTService, CartesiaSTTSettings -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55n-update-settings-cartesia-http-tts.py b/examples/foundational/55n-update-settings-cartesia-http-tts.py index 0423d855f..a58a8a778 100644 --- a/examples/foundational/55n-update-settings-cartesia-http-tts.py +++ b/examples/foundational/55n-update-settings-cartesia-http-tts.py @@ -58,7 +58,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaHttpTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55n-update-settings-cartesia-tts.py b/examples/foundational/55n-update-settings-cartesia-tts.py index 2ee07b830..e729c53f2 100644 --- a/examples/foundational/55n-update-settings-cartesia-tts.py +++ b/examples/foundational/55n-update-settings-cartesia-tts.py @@ -56,7 +56,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zi-update-settings-azure-llm.py b/examples/foundational/55zi-update-settings-azure-llm.py index b6e8ccf71..29748491b 100644 --- a/examples/foundational/55zi-update-settings-azure-llm.py +++ b/examples/foundational/55zi-update-settings-azure-llm.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.azure.llm import AzureLLMService -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AzureLLMService( diff --git a/examples/foundational/55zi-update-settings-openai-llm.py b/examples/foundational/55zi-update-settings-openai-llm.py index c9fb026f3..123fc7a04 100644 --- a/examples/foundational/55zi-update-settings-openai-llm.py +++ b/examples/foundational/55zi-update-settings-openai-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openai.llm import OpenAILLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zj-update-settings-anthropic-llm.py b/examples/foundational/55zj-update-settings-anthropic-llm.py index 59ac73da6..d44102f2d 100644 --- a/examples/foundational/55zj-update-settings-anthropic-llm.py +++ b/examples/foundational/55zj-update-settings-anthropic-llm.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.anthropic.llm import AnthropicLLMService, AnthropicLLMSettings -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,7 +54,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AnthropicLLMService( diff --git a/examples/foundational/55zk-update-settings-google-llm.py b/examples/foundational/55zk-update-settings-google-llm.py index 4a0a3de0f..d1222e422 100644 --- a/examples/foundational/55zk-update-settings-google-llm.py +++ b/examples/foundational/55zk-update-settings-google-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMService, GoogleLLMSettings from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -54,7 +54,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleLLMService( diff --git a/examples/foundational/55zk-update-settings-google-vertex-llm.py b/examples/foundational/55zk-update-settings-google-vertex-llm.py index fe8ef808b..aa9452d09 100644 --- a/examples/foundational/55zk-update-settings-google-vertex-llm.py +++ b/examples/foundational/55zk-update-settings-google-vertex-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.google.llm import GoogleLLMSettings from pipecat.services.google.llm_vertex import GoogleVertexLLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GoogleVertexLLMService( diff --git a/examples/foundational/55zp-update-settings-aws-bedrock-llm.py b/examples/foundational/55zp-update-settings-aws-bedrock-llm.py index 72b5ae9be..c543ef50c 100644 --- a/examples/foundational/55zp-update-settings-aws-bedrock-llm.py +++ b/examples/foundational/55zp-update-settings-aws-bedrock-llm.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport from pipecat.services.aws.llm import AWSBedrockLLMService, AWSBedrockLLMSettings -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.transports.base_transport import BaseTransport, TransportParams from pipecat.transports.daily.transport import DailyParams @@ -54,7 +54,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = AWSBedrockLLMService( diff --git a/examples/foundational/55zq-update-settings-fal-stt.py b/examples/foundational/55zq-update-settings-fal-stt.py index 22ee38929..96f916d81 100644 --- a/examples/foundational/55zq-update-settings-fal-stt.py +++ b/examples/foundational/55zq-update-settings-fal-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.fal.stt import FalSTTService, FalSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -54,7 +54,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zr-update-settings-gradium-stt.py b/examples/foundational/55zr-update-settings-gradium-stt.py index 65c70519d..0b3085125 100644 --- a/examples/foundational/55zr-update-settings-gradium-stt.py +++ b/examples/foundational/55zr-update-settings-gradium-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.gradium.stt import GradiumSTTService, GradiumSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zt-update-settings-nvidia-segmented-stt.py b/examples/foundational/55zt-update-settings-nvidia-segmented-stt.py index 122619aaa..55a6719be 100644 --- a/examples/foundational/55zt-update-settings-nvidia-segmented-stt.py +++ b/examples/foundational/55zt-update-settings-nvidia-segmented-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.nvidia.stt import NvidiaSegmentedSTTService, NvidiaSegmentedSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -54,7 +54,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zt-update-settings-nvidia-stt.py b/examples/foundational/55zt-update-settings-nvidia-stt.py index 232db9bf3..2f15895d2 100644 --- a/examples/foundational/55zt-update-settings-nvidia-stt.py +++ b/examples/foundational/55zt-update-settings-nvidia-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.nvidia.stt import NvidiaSTTService, NvidiaSTTSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zu-update-settings-openai-realtime-stt.py b/examples/foundational/55zu-update-settings-openai-realtime-stt.py index eb7be5c97..7cc31085b 100644 --- a/examples/foundational/55zu-update-settings-openai-realtime-stt.py +++ b/examples/foundational/55zu-update-settings-openai-realtime-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.openai.stt import OpenAIRealtimeSTTService, OpenAIRealtimeSTTSettings from pipecat.transcriptions.language import Language @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/55zx-update-settings-cerebras-llm.py b/examples/foundational/55zx-update-settings-cerebras-llm.py index 3937345e1..dc09cdae7 100644 --- a/examples/foundational/55zx-update-settings-cerebras-llm.py +++ b/examples/foundational/55zx-update-settings-cerebras-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.cerebras.llm import CerebrasLLMService from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = CerebrasLLMService( diff --git a/examples/foundational/55zy-update-settings-deepseek-llm.py b/examples/foundational/55zy-update-settings-deepseek-llm.py index c96107c40..fe6e18185 100644 --- a/examples/foundational/55zy-update-settings-deepseek-llm.py +++ b/examples/foundational/55zy-update-settings-deepseek-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.deepseek.llm import DeepSeekLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = DeepSeekLLMService( diff --git a/examples/foundational/55zz-update-settings-fireworks-llm.py b/examples/foundational/55zz-update-settings-fireworks-llm.py index 8c4388251..19b9276e6 100644 --- a/examples/foundational/55zz-update-settings-fireworks-llm.py +++ b/examples/foundational/55zz-update-settings-fireworks-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.fireworks.llm import FireworksLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = FireworksLLMService( diff --git a/examples/foundational/55zza-update-settings-grok-llm.py b/examples/foundational/55zza-update-settings-grok-llm.py index e75c70b5f..c40f40ac6 100644 --- a/examples/foundational/55zza-update-settings-grok-llm.py +++ b/examples/foundational/55zza-update-settings-grok-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.grok.llm import GrokLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GrokLLMService( diff --git a/examples/foundational/55zzb-update-settings-groq-llm.py b/examples/foundational/55zzb-update-settings-groq-llm.py index 2f7f82bb2..be5467b8a 100644 --- a/examples/foundational/55zzb-update-settings-groq-llm.py +++ b/examples/foundational/55zzb-update-settings-groq-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.groq.llm import GroqLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = GroqLLMService( diff --git a/examples/foundational/55zzc-update-settings-mistral-llm.py b/examples/foundational/55zzc-update-settings-mistral-llm.py index ab3bd4f76..f6fa824d4 100644 --- a/examples/foundational/55zzc-update-settings-mistral-llm.py +++ b/examples/foundational/55zzc-update-settings-mistral-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.mistral.llm import MistralLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = MistralLLMService( diff --git a/examples/foundational/55zzd-update-settings-nvidia-llm.py b/examples/foundational/55zzd-update-settings-nvidia-llm.py index a8699c71b..5e26e8213 100644 --- a/examples/foundational/55zzd-update-settings-nvidia-llm.py +++ b/examples/foundational/55zzd-update-settings-nvidia-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.nvidia.llm import NvidiaLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = NvidiaLLMService( diff --git a/examples/foundational/55zze-update-settings-ollama-llm.py b/examples/foundational/55zze-update-settings-ollama-llm.py index 4595604fd..7e3fa02de 100644 --- a/examples/foundational/55zze-update-settings-ollama-llm.py +++ b/examples/foundational/55zze-update-settings-ollama-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.ollama.llm import OLLamaLLMService from pipecat.services.openai.base_llm import OpenAILLMSettings @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OLLamaLLMService( diff --git a/examples/foundational/55zzf-update-settings-openrouter-llm.py b/examples/foundational/55zzf-update-settings-openrouter-llm.py index 9a381d88b..c31a7c43c 100644 --- a/examples/foundational/55zzf-update-settings-openrouter-llm.py +++ b/examples/foundational/55zzf-update-settings-openrouter-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.openrouter.llm import OpenRouterLLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenRouterLLMService( diff --git a/examples/foundational/55zzg-update-settings-perplexity-llm.py b/examples/foundational/55zzg-update-settings-perplexity-llm.py index f55975685..5227c6063 100644 --- a/examples/foundational/55zzg-update-settings-perplexity-llm.py +++ b/examples/foundational/55zzg-update-settings-perplexity-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.perplexity.llm import PerplexityLLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = PerplexityLLMService(api_key=os.getenv("PERPLEXITY_API_KEY")) diff --git a/examples/foundational/55zzh-update-settings-qwen-llm.py b/examples/foundational/55zzh-update-settings-qwen-llm.py index 019e916cb..5c6d17d1d 100644 --- a/examples/foundational/55zzh-update-settings-qwen-llm.py +++ b/examples/foundational/55zzh-update-settings-qwen-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.qwen.llm import QwenLLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = QwenLLMService( diff --git a/examples/foundational/55zzi-update-settings-sambanova-llm.py b/examples/foundational/55zzi-update-settings-sambanova-llm.py index 040e95da1..cececc078 100644 --- a/examples/foundational/55zzi-update-settings-sambanova-llm.py +++ b/examples/foundational/55zzi-update-settings-sambanova-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.sambanova.llm import SambaNovaLLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = SambaNovaLLMService( diff --git a/examples/foundational/55zzj-update-settings-together-llm.py b/examples/foundational/55zzj-update-settings-together-llm.py index b1c8c049d..4e1c9732f 100644 --- a/examples/foundational/55zzj-update-settings-together-llm.py +++ b/examples/foundational/55zzj-update-settings-together-llm.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.base_llm import OpenAILLMSettings from pipecat.services.together.llm import TogetherLLMService @@ -55,7 +55,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = TogetherLLMService( diff --git a/examples/foundational/55zzn-update-settings-groq-stt.py b/examples/foundational/55zzn-update-settings-groq-stt.py index 1d488119c..7a8551be2 100644 --- a/examples/foundational/55zzn-update-settings-groq-stt.py +++ b/examples/foundational/55zzn-update-settings-groq-stt.py @@ -22,7 +22,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.groq.stt import GroqSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.services.whisper.base_stt import BaseWhisperSTTSettings @@ -57,7 +57,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService( diff --git a/examples/foundational/56-lemonslice-transport.py b/examples/foundational/56-lemonslice-transport.py index a3b6b60d3..6085f3b00 100644 --- a/examples/foundational/56-lemonslice-transport.py +++ b/examples/foundational/56-lemonslice-transport.py @@ -23,7 +23,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( LLMUserAggregatorParams, ) from pipecat.services.deepgram.stt import DeepgramSTTService -from pipecat.services.elevenlabs.tts import ElevenLabsTTSService +from pipecat.services.elevenlabs.tts import ElevenLabsTTSService, ElevenLabsTTSSettings from pipecat.services.groq.llm import GroqLLMService from pipecat.transports.lemonslice.transport import ( LemonSliceNewSessionRequest, @@ -62,7 +62,9 @@ async def main(): tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), - voice_id=os.getenv("ELEVENLABS_VOICE_ID", ""), + settings=ElevenLabsTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) context = LLMContext() diff --git a/examples/quickstart/bot.py b/examples/quickstart/bot.py index fbe27d783..956331d50 100644 --- a/examples/quickstart/bot.py +++ b/examples/quickstart/bot.py @@ -45,7 +45,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( ) from pipecat.runner.types import RunnerArguments from pipecat.runner.utils import create_transport -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.openai.llm import OpenAILLMService from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -63,7 +63,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = CartesiaTTSService( api_key=os.getenv("CARTESIA_API_KEY"), - voice_id="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + settings=CartesiaTTSSettings( + voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady + ), ) llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) diff --git a/scripts/evals/eval.py b/scripts/evals/eval.py index 91971aee7..28469e40a 100644 --- a/scripts/evals/eval.py +++ b/scripts/evals/eval.py @@ -49,7 +49,7 @@ from pipecat.processors.aggregators.llm_response_universal import ( from pipecat.processors.audio.audio_buffer_processor import AudioBufferProcessor from pipecat.processors.frame_processor import FrameDirection from pipecat.runner.types import RunnerArguments -from pipecat.services.cartesia.tts import CartesiaTTSService +from pipecat.services.cartesia.tts import CartesiaTTSService, CartesiaTTSSettings from pipecat.services.deepgram.stt import DeepgramSTTService from pipecat.services.llm_service import FunctionCallParams from pipecat.services.openai.llm import OpenAILLMService diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index 257a58501..d740f4ec0 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -320,7 +320,7 @@ class BaseOpenAILLMService(LLMService): "top_p": self._settings.top_p, "max_tokens": self._settings.max_tokens, "max_completion_tokens": self._settings.max_completion_tokens, - "service_tier": self._service_tier, + "service_tier": self._service_tier if self._service_tier is not None else NOT_GIVEN, } # Messages, tools, tool_choice diff --git a/src/pipecat/services/sarvam/tts.py b/src/pipecat/services/sarvam/tts.py index 659a58bdd..0d605fc6b 100644 --- a/src/pipecat/services/sarvam/tts.py +++ b/src/pipecat/services/sarvam/tts.py @@ -272,37 +272,22 @@ class SarvamHttpTTSSettings(TTSSettings): @dataclass -class SarvamTTSSettings(TTSSettings): +class SarvamTTSSettings(SarvamHttpTTSSettings): """Settings for Sarvam WebSocket TTS service. + Extends :class:`SarvamHttpTTSSettings` with WebSocket-specific buffering parameters. + Parameters: - enable_preprocessing: Enable text preprocessing. Defaults to False. - **Note:** Always enabled for bulbul:v3-beta. min_buffer_size: Minimum characters to buffer before generating audio. Lower values reduce latency but may affect quality. Defaults to 50. max_chunk_length: Maximum characters processed in a single chunk. Controls memory usage and processing efficiency. Defaults to 150. - pace: Speech pace multiplier. Defaults to 1.0. - - bulbul:v2: Range 0.3 to 3.0 - - bulbul:v3-beta: Range 0.5 to 2.0 - pitch: Voice pitch adjustment (-0.75 to 0.75). Defaults to 0.0. - **Note:** Only supported for bulbul:v2. Ignored for v3 models. - loudness: Volume multiplier (0.3 to 3.0). Defaults to 1.0. - **Note:** Only supported for bulbul:v2. Ignored for v3 models. - temperature: Controls output randomness for bulbul:v3-beta (0.01 to 1.0). - Lower = more deterministic, higher = more random. Defaults to 0.6. - **Note:** Only supported for bulbul:v3-beta. Ignored for v2. """ _aliases: ClassVar[Dict[str, str]] = {"target_language_code": "language"} - enable_preprocessing: bool | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) min_buffer_size: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) max_chunk_length: int | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - pace: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - pitch: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - loudness: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) - temperature: float | None | _NotGiven = field(default_factory=lambda: NOT_GIVEN) class SarvamHttpTTSService(TTSService):