From 58a17c7b1bde8deb899e10d68f0abef979850245 Mon Sep 17 00:00:00 2001 From: Mark Backman Date: Mon, 20 Apr 2026 15:50:49 -0400 Subject: [PATCH] Include examples in type checking Remove `examples/` from the `pyrightconfig.json` ignore list and fix the resulting type errors across all example files. Common fixes: - Required API keys: `os.getenv("X")` -> `os.environ["X"]` so the return type is `str` rather than `str | None`, and misconfiguration fails fast. - Narrow `LLMContextMessage` union members with `isinstance(..., dict)` before dict-style access. - `assert isinstance(params.llm, ...)` before calling service-specific methods that aren't on the base `LLMService`. - Guard optional frame fields (e.g. `LLMSearchResponseFrame.search_result`) before use. --- examples/audio/audio-bot-background-sound.py | 6 +- examples/audio/audio-recording.py | 6 +- examples/audio/audio-sound-effects.py | 6 +- .../context-summarization-dedicated-llm.py | 8 +- .../context-summarization-google.py | 6 +- .../context-summarization-manual-openai.py | 6 +- .../context-summarization-openai.py | 6 +- .../features-before-and-after-events.py | 6 +- .../features-concurrent-llm-evaluation.py | 8 +- ...res-concurrent-llm-rtvi-ignored-sources.py | 8 +- .../features-custom-frame-processor.py | 6 +- .../features-gpu-container-local-bot.py | 6 +- .../features/features-live-translation.py | 6 +- .../features-pattern-pair-voice-switching.py | 6 +- .../features/features-service-switcher.py | 12 +- .../features/features-switch-languages.py | 8 +- examples/features/features-switch-voices.py | 10 +- .../features/features-user-email-gathering.py | 6 +- .../features/features-voicemail-detection.py | 8 +- examples/features/features-wake-phrase.py | 6 +- ...function-calling-anthropic-async-stream.py | 6 +- .../function-calling-anthropic-async.py | 6 +- .../function-calling-anthropic-video.py | 6 +- .../function-calling-anthropic.py | 6 +- .../function-calling-aws-video.py | 4 +- .../function-calling-azure.py | 8 +- .../function-calling-cerebras.py | 6 +- .../function-calling-deepseek.py | 6 +- .../function-calling-direct.py | 6 +- .../function-calling-fireworks.py | 6 +- .../function-calling-google-async-stream.py | 6 +- .../function-calling-google-async.py | 6 +- .../function-calling-google-vertex.py | 27 ++-- .../function-calling-google-video.py | 6 +- .../function-calling-google.py | 6 +- .../function-calling/function-calling-grok.py | 6 +- .../function-calling/function-calling-groq.py | 6 +- .../function-calling-mistral.py | 6 +- .../function-calling-moondream-video.py | 6 +- .../function-calling-nebius.py | 6 +- .../function-calling-novita.py | 6 +- .../function-calling-nvidia.py | 6 +- .../function-calling-ollama.py | 4 +- .../function-calling-openai-async-stream.py | 6 +- .../function-calling-openai-async.py | 6 +- ...n-calling-openai-responses-async-stream.py | 6 +- ...function-calling-openai-responses-async.py | 6 +- .../function-calling-openai-responses-http.py | 6 +- ...ion-calling-openai-responses-video-http.py | 6 +- ...function-calling-openai-responses-video.py | 6 +- .../function-calling-openai-responses.py | 6 +- .../function-calling-openai-video.py | 6 +- .../function-calling-openai.py | 6 +- .../function-calling-openrouter.py | 8 +- .../function-calling-perplexity.py | 6 +- .../function-calling/function-calling-qwen.py | 6 +- .../function-calling-sambanova.py | 6 +- .../function-calling-sarvam.py | 6 +- .../function-calling-together.py | 6 +- examples/getting-started/01-say-one-thing.py | 2 +- examples/getting-started/01a-local-audio.py | 2 +- .../getting-started/02-llm-say-one-thing.py | 4 +- examples/getting-started/03-still-frame.py | 2 +- .../04-sync-speech-and-image.py | 4 +- examples/getting-started/05-speaking-state.py | 6 +- examples/getting-started/06-voice-agent.py | 6 +- .../getting-started/06a-voice-agent-local.py | 6 +- .../getting-started/07-function-calling.py | 6 +- examples/mcp/mcp-multiple-mcp.py | 6 +- examples/mcp/mcp-stdio.py | 6 +- .../mcp/mcp-streamable-http-gemini-live.py | 13 +- examples/mcp/mcp-streamable-http.py | 6 +- .../observability/observability-observer.py | 6 +- .../observability-sentry-metrics.py | 6 +- .../persistent-context-anthropic.py | 6 +- .../persistent-context-aws-nova-sonic.py | 11 +- .../persistent-context-gemini.py | 6 +- .../persistent-context-grok-realtime.py | 2 +- .../persistent-context-openai-realtime.py | 5 +- ...ersistent-context-openai-responses-http.py | 6 +- .../persistent-context-openai-responses.py | 6 +- .../persistent-context-openai.py | 6 +- examples/rag/rag-gemini-grounding-metadata.py | 6 +- examples/rag/rag-gemini.py | 8 +- examples/rag/rag-mem0.py | 6 +- examples/realtime/realtime-aws-nova-sonic.py | 6 +- examples/realtime/realtime-azure.py | 4 +- .../realtime-gemini-live-files-api.py | 2 +- .../realtime-gemini-live-function-calling.py | 2 +- .../realtime-gemini-live-google-search.py | 2 +- .../realtime-gemini-live-graceful-end.py | 2 +- ...realtime-gemini-live-grounding-metadata.py | 21 ++- .../realtime-gemini-live-local-vad.py | 2 +- ...ime-gemini-live-vertex-function-calling.py | 4 +- .../realtime/realtime-gemini-live-video.py | 2 +- examples/realtime/realtime-gemini-live.py | 2 +- examples/realtime/realtime-grok.py | 2 +- examples/realtime/realtime-inworld.py | 2 +- .../realtime/realtime-openai-live-video.py | 6 +- examples/realtime/realtime-openai-text.py | 4 +- examples/realtime/realtime-openai.py | 2 +- examples/realtime/realtime-ultravox-text.py | 2 +- examples/realtime/realtime-ultravox.py | 2 +- examples/thinking/thinking-anthropic.py | 6 +- .../thinking/thinking-functions-anthropic.py | 6 +- .../thinking/thinking-functions-google.py | 6 +- examples/thinking/thinking-google.py | 6 +- .../transcription/transcription-assemblyai.py | 2 +- examples/transcription/transcription-azure.py | 2 +- .../transcription/transcription-cartesia.py | 2 +- .../transcription/transcription-deepgram.py | 2 +- .../transcription/transcription-elevenlabs.py | 2 +- .../transcription-gladia-translation.py | 7 +- .../transcription/transcription-gladia.py | 7 +- .../transcription/transcription-google-llm.py | 6 +- .../transcription/transcription-gradium.py | 2 +- .../transcription/transcription-mistral.py | 2 +- .../transcription/transcription-openai.py | 2 +- .../transcription/transcription-soniox.py | 2 +- .../transcription-speechmatics.py | 2 +- examples/transports/transports-daily.py | 4 +- examples/transports/transports-livekit.py | 6 +- .../transports/transports-small-webrtc.py | 6 +- .../turn-management-detect-user-idle.py | 9 +- ...turn-management-filter-incomplete-turns.py | 6 +- .../turn-management-interruption-config.py | 6 +- ...turn-management-smart-turn-local-coreml.py | 8 +- .../turn-management-smart-turn-local.py | 6 +- .../turn-management-turn-tracking-observer.py | 6 +- .../turn-management-user-assistant-turns.py | 6 +- .../turn-management-user-mute-strategy.py | 6 +- examples/update-settings/llm/llm-anthropic.py | 6 +- .../update-settings/llm/llm-aws-bedrock.py | 4 +- .../update-settings/llm/llm-aws-nova-sonic.py | 6 +- .../update-settings/llm/llm-azure-realtime.py | 7 +- examples/update-settings/llm/llm-azure.py | 8 +- examples/update-settings/llm/llm-cerebras.py | 6 +- examples/update-settings/llm/llm-deepseek.py | 6 +- examples/update-settings/llm/llm-fireworks.py | 6 +- .../llm/llm-gemini-live-vertex.py | 6 +- .../update-settings/llm/llm-gemini-live.py | 2 +- .../update-settings/llm/llm-google-vertex.py | 8 +- examples/update-settings/llm/llm-google.py | 6 +- .../update-settings/llm/llm-grok-realtime.py | 5 +- examples/update-settings/llm/llm-grok.py | 6 +- examples/update-settings/llm/llm-groq.py | 6 +- examples/update-settings/llm/llm-mistral.py | 6 +- examples/update-settings/llm/llm-nvidia.py | 6 +- examples/update-settings/llm/llm-ollama.py | 4 +- .../llm/llm-openai-realtime.py | 5 +- .../llm/llm-openai-responses-http.py | 6 +- .../llm/llm-openai-responses.py | 6 +- examples/update-settings/llm/llm-openai.py | 6 +- .../update-settings/llm/llm-openrouter.py | 6 +- .../update-settings/llm/llm-perplexity.py | 18 +-- examples/update-settings/llm/llm-qwen.py | 6 +- examples/update-settings/llm/llm-sambanova.py | 6 +- examples/update-settings/llm/llm-sarvam.py | 21 ++- examples/update-settings/llm/llm-together.py | 6 +- .../llm/llm-ultravox-realtime.py | 5 +- .../update-settings/stt/stt-assemblyai.py | 6 +- .../update-settings/stt/stt-aws-transcribe.py | 4 +- examples/update-settings/stt/stt-azure.py | 6 +- examples/update-settings/stt/stt-cartesia.py | 6 +- .../update-settings/stt/stt-deepgram-flux.py | 6 +- .../stt/stt-deepgram-sagemaker.py | 8 +- examples/update-settings/stt/stt-deepgram.py | 6 +- .../stt/stt-elevenlabs-realtime.py | 6 +- .../update-settings/stt/stt-elevenlabs.py | 6 +- examples/update-settings/stt/stt-fal.py | 4 +- examples/update-settings/stt/stt-gladia.py | 6 +- examples/update-settings/stt/stt-google.py | 6 +- examples/update-settings/stt/stt-gradium.py | 6 +- examples/update-settings/stt/stt-groq.py | 6 +- .../stt/stt-nvidia-segmented.py | 6 +- examples/update-settings/stt/stt-nvidia.py | 6 +- .../stt/stt-openai-realtime.py | 6 +- examples/update-settings/stt/stt-sarvam.py | 6 +- examples/update-settings/stt/stt-soniox.py | 6 +- .../update-settings/stt/stt-speechmatics.py | 6 +- .../update-settings/stt/stt-whisper-api.py | 6 +- .../update-settings/stt/stt-whisper-mlx.py | 4 +- examples/update-settings/stt/stt-whisper.py | 4 +- .../update-settings/tts/tts-asyncai-http.py | 4 +- examples/update-settings/tts/tts-asyncai.py | 4 +- examples/update-settings/tts/tts-aws-polly.py | 4 +- .../update-settings/tts/tts-azure-http.py | 8 +- examples/update-settings/tts/tts-azure.py | 8 +- examples/update-settings/tts/tts-camb.py | 6 +- .../update-settings/tts/tts-cartesia-http.py | 6 +- examples/update-settings/tts/tts-cartesia.py | 6 +- .../update-settings/tts/tts-deepgram-http.py | 6 +- .../tts/tts-deepgram-sagemaker.py | 8 +- examples/update-settings/tts/tts-deepgram.py | 6 +- .../tts/tts-elevenlabs-http.py | 13 +- .../update-settings/tts/tts-elevenlabs.py | 20 ++- examples/update-settings/tts/tts-fish.py | 6 +- examples/update-settings/tts/tts-gemini.py | 6 +- .../update-settings/tts/tts-google-http.py | 6 +- .../update-settings/tts/tts-google-stream.py | 6 +- examples/update-settings/tts/tts-gradium.py | 6 +- examples/update-settings/tts/tts-groq.py | 6 +- examples/update-settings/tts/tts-hume.py | 4 +- .../update-settings/tts/tts-inworld-http.py | 6 +- examples/update-settings/tts/tts-inworld.py | 6 +- examples/update-settings/tts/tts-kokoro.py | 4 +- examples/update-settings/tts/tts-lmnt.py | 6 +- examples/update-settings/tts/tts-minimax.py | 8 +- .../update-settings/tts/tts-neuphonic-http.py | 6 +- examples/update-settings/tts/tts-neuphonic.py | 6 +- examples/update-settings/tts/tts-nvidia.py | 6 +- examples/update-settings/tts/tts-openai.py | 6 +- .../update-settings/tts/tts-piper-http.py | 6 +- examples/update-settings/tts/tts-piper.py | 4 +- .../update-settings/tts/tts-resembleai.py | 10 +- examples/update-settings/tts/tts-rime-http.py | 6 +- examples/update-settings/tts/tts-rime.py | 6 +- .../update-settings/tts/tts-sarvam-http.py | 6 +- examples/update-settings/tts/tts-sarvam.py | 6 +- .../update-settings/tts/tts-speechmatics.py | 6 +- examples/update-settings/tts/tts-xtts.py | 4 +- .../video-avatar-heygen-transport.py | 8 +- .../video-avatar-heygen-video-service.py | 8 +- .../video-avatar-lemonslice-transport.py | 6 +- .../video-avatar-simli-video-service.py | 8 +- .../video-avatar-tavus-transport.py | 10 +- .../video-avatar-tavus-video-service.py | 10 +- examples/video-processing/video-processing.py | 17 ++- examples/vision/vision-anthropic.py | 6 +- examples/vision/vision-aws.py | 4 +- examples/vision/vision-gemini-flash.py | 6 +- examples/vision/vision-moondream.py | 2 +- .../vision/vision-openai-responses-http.py | 6 +- examples/vision/vision-openai-responses.py | 6 +- examples/vision/vision-openai.py | 6 +- examples/voice/voice-aicoustics.py | 6 +- .../voice/voice-assemblyai-turn-detection.py | 6 +- examples/voice/voice-assemblyai.py | 6 +- examples/voice/voice-asyncai-http.py | 4 +- examples/voice/voice-asyncai.py | 4 +- examples/voice/voice-azure-http.py | 10 +- examples/voice/voice-azure.py | 10 +- examples/voice/voice-camb.py | 6 +- examples/voice/voice-cartesia-http.py | 6 +- examples/voice/voice-cartesia.py | 6 +- .../voice/voice-deepgram-flux-sagemaker.py | 8 +- examples/voice/voice-deepgram-flux.py | 6 +- examples/voice/voice-deepgram-http.py | 6 +- examples/voice/voice-deepgram-sagemaker.py | 8 +- examples/voice/voice-deepgram-vad.py | 133 ------------------ examples/voice/voice-deepgram.py | 6 +- examples/voice/voice-elevenlabs-http.py | 4 +- examples/voice/voice-elevenlabs.py | 4 +- examples/voice/voice-fal.py | 4 +- examples/voice/voice-fish.py | 6 +- examples/voice/voice-gladia-vad.py | 7 +- examples/voice/voice-gladia.py | 7 +- examples/voice/voice-google-audio-in.py | 4 +- examples/voice/voice-google-gemini-tts.py | 6 +- examples/voice/voice-google-http.py | 6 +- examples/voice/voice-google-image.py | 6 +- examples/voice/voice-google.py | 6 +- examples/voice/voice-gradium.py | 6 +- examples/voice/voice-groq.py | 6 +- examples/voice/voice-hume.py | 4 +- examples/voice/voice-inworld-http.py | 4 +- examples/voice/voice-inworld.py | 4 +- examples/voice/voice-kokoro.py | 4 +- examples/voice/voice-krisp-viva.py | 6 +- examples/voice/voice-langchain.py | 12 +- examples/voice/voice-lmnt.py | 6 +- examples/voice/voice-minimax.py | 4 +- examples/voice/voice-mistral.py | 6 +- examples/voice/voice-neuphonic-http.py | 6 +- examples/voice/voice-neuphonic.py | 6 +- examples/voice/voice-nvidia.py | 6 +- examples/voice/voice-openai-http.py | 6 +- examples/voice/voice-openai-responses-http.py | 6 +- examples/voice/voice-openai-responses.py | 6 +- examples/voice/voice-openai.py | 6 +- examples/voice/voice-piper.py | 4 +- examples/voice/voice-resemble.py | 8 +- examples/voice/voice-rime-http.py | 4 +- examples/voice/voice-rime.py | 4 +- examples/voice/voice-sarvam-http.py | 6 +- examples/voice/voice-sarvam.py | 6 +- examples/voice/voice-smallest.py | 6 +- examples/voice/voice-soniox.py | 6 +- examples/voice/voice-speechmatics-vad.py | 6 +- examples/voice/voice-speechmatics.py | 6 +- examples/voice/voice-xai.py | 6 +- examples/voice/voice-xtts.py | 4 +- pyrightconfig.json | 6 +- 293 files changed, 884 insertions(+), 1006 deletions(-) delete mode 100644 examples/voice/voice-deepgram-vad.py diff --git a/examples/audio/audio-bot-background-sound.py b/examples/audio/audio-bot-background-sound.py index 4237bb625..6417e5549 100644 --- a/examples/audio/audio-bot-background-sound.py +++ b/examples/audio/audio-bot-background-sound.py @@ -71,17 +71,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/audio/audio-recording.py b/examples/audio/audio-recording.py index 68354e0dd..9ece2b796 100644 --- a/examples/audio/audio-recording.py +++ b/examples/audio/audio-recording.py @@ -108,17 +108,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY"), audio_passthrough=True) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"], audio_passthrough=True) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/audio/audio-sound-effects.py b/examples/audio/audio-sound-effects.py index 1f7fdd339..19ed85675 100644 --- a/examples/audio/audio-sound-effects.py +++ b/examples/audio/audio-sound-effects.py @@ -102,17 +102,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/context-summarization/context-summarization-dedicated-llm.py b/examples/context-summarization/context-summarization-dedicated-llm.py index e4de35cb7..bc13e9c46 100644 --- a/examples/context-summarization/context-summarization-dedicated-llm.py +++ b/examples/context-summarization/context-summarization-dedicated-llm.py @@ -89,10 +89,10 @@ async def get_current_weather(params: FunctionCallParams): async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info("Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -109,7 +109,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Primary LLM for conversation (could be any provider) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction=system_prompt, ), @@ -117,7 +117,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Dedicated cheap/fast LLM for summarization only summarization_llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( model="gemini-2.5-flash", ), diff --git a/examples/context-summarization/context-summarization-google.py b/examples/context-summarization/context-summarization-google.py index f8cf50419..3b0daca32 100644 --- a/examples/context-summarization/context-summarization-google.py +++ b/examples/context-summarization/context-summarization-google.py @@ -77,17 +77,17 @@ async def get_current_weather(params: FunctionCallParams): async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info("Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You have access to tools to get the current weather - use them when relevant.", ), diff --git a/examples/context-summarization/context-summarization-manual-openai.py b/examples/context-summarization/context-summarization-manual-openai.py index 017831695..23f70d97c 100644 --- a/examples/context-summarization/context-summarization-manual-openai.py +++ b/examples/context-summarization/context-summarization-manual-openai.py @@ -72,10 +72,10 @@ async def summarize_conversation(params: FunctionCallParams): async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info("Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -91,7 +91,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): """ llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction=system_prompt, ), diff --git a/examples/context-summarization/context-summarization-openai.py b/examples/context-summarization/context-summarization-openai.py index 53c5b26a5..05566f32b 100644 --- a/examples/context-summarization/context-summarization-openai.py +++ b/examples/context-summarization/context-summarization-openai.py @@ -77,17 +77,17 @@ async def get_current_weather(params: FunctionCallParams): async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info("Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You have access to tools to get the current weather - use them when relevant.", ), diff --git a/examples/features/features-before-and-after-events.py b/examples/features/features-before-and-after-events.py index b9111b945..dedf3c4fa 100644 --- a/examples/features/features-before-and-after-events.py +++ b/examples/features/features-before-and-after-events.py @@ -63,17 +63,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/features/features-concurrent-llm-evaluation.py b/examples/features/features-concurrent-llm-evaluation.py index 25b9372d0..cb085a8c7 100644 --- a/examples/features/features-concurrent-llm-evaluation.py +++ b/examples/features/features-concurrent-llm-evaluation.py @@ -58,24 +58,24 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) openai_llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), ) groq_llm = GroqLLMService( - api_key=os.getenv("GROQ_API_KEY"), + api_key=os.environ["GROQ_API_KEY"], settings=GroqLLMService.Settings( system_instruction="You are a very helpful assistant. Your goal is to demonstrate your capabilities in detail in a creative and helpful way.", ), diff --git a/examples/features/features-concurrent-llm-rtvi-ignored-sources.py b/examples/features/features-concurrent-llm-rtvi-ignored-sources.py index 678c56a0b..70530b51e 100644 --- a/examples/features/features-concurrent-llm-rtvi-ignored-sources.py +++ b/examples/features/features-concurrent-llm-rtvi-ignored-sources.py @@ -63,10 +63,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info("Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -74,7 +74,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Main LLM — drives the conversation. Its RTVI events reach the client. main_llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), @@ -83,7 +83,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # 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"), + api_key=os.environ["OPENAI_API_KEY"], name="EvaluatorLLM", settings=OpenAILLMService.Settings( 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.", diff --git a/examples/features/features-custom-frame-processor.py b/examples/features/features-custom-frame-processor.py index bf143c40d..ab82bae80 100644 --- a/examples/features/features-custom-frame-processor.py +++ b/examples/features/features-custom-frame-processor.py @@ -91,17 +91,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/features/features-gpu-container-local-bot.py b/examples/features/features-gpu-container-local-bot.py index c61870866..67a8dabc7 100644 --- a/examples/features/features-gpu-container-local-bot.py +++ b/examples/features/features-gpu-container-local-bot.py @@ -56,10 +56,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = DeepgramTTSService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], settings=DeepgramTTSService.Settings( voice="aura-asteria-en", ), @@ -68,7 +68,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = OpenAILLMService( # To use OpenAI - # api_key=os.getenv("OPENAI_API_KEY"), + # api_key=os.environ["OPENAI_API_KEY"], # Or, to use a local vLLM (or similar) api server settings=OpenAILLMService.Settings( model="meta-llama/Meta-Llama-3-8B-Instruct", diff --git a/examples/features/features-live-translation.py b/examples/features/features-live-translation.py index 7a4a4b112..e4e7d075f 100644 --- a/examples/features/features-live-translation.py +++ b/examples/features/features-live-translation.py @@ -55,17 +55,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="d4db5fb9-f44b-4bd1-85fa-192e0f0d75f9", # Spanish-speaking Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a live translation assistant. Your sole purpose is to translate English text into Spanish. When you receive English text from the user, immediately translate it into natural, fluent Spanish. Do not add explanations, commentary, or extra information—only provide the Spanish translation of the text you receive.", ), diff --git a/examples/features/features-pattern-pair-voice-switching.py b/examples/features/features-pattern-pair-voice-switching.py index 38926d915..1f5b83cb8 100644 --- a/examples/features/features-pattern-pair-voice-switching.py +++ b/examples/features/features-pattern-pair-voice-switching.py @@ -126,14 +126,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm_text_aggregator.on_pattern_match("voice", on_voice_tag) - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) # Process LLM text through the pattern aggregator before TTS llm_text_processor = LLMTextProcessor(text_aggregator=llm_text_aggregator) # Initialize TTS with narrator voice as default tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice=VOICE_IDS["narrator"], ), @@ -190,7 +190,7 @@ Remember: Use narrator voice for EVERYTHING except the actual quoted dialogue."" # Initialize LLM llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction=system_prompt, ), diff --git a/examples/features/features-service-switcher.py b/examples/features/features-service-switcher.py index 9ded72a60..c2c78738a 100644 --- a/examples/features/features-service-switcher.py +++ b/examples/features/features-service-switcher.py @@ -94,19 +94,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): required=["location", "format"], ) - stt_cartesia = CartesiaSTTService(api_key=os.getenv("CARTESIA_API_KEY")) - stt_deepgram = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt_cartesia = CartesiaSTTService(api_key=os.environ["CARTESIA_API_KEY"]) + stt_deepgram = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) # Uses ServiceSwitcherStrategyManual by default stt_switcher = ServiceSwitcher(services=[stt_cartesia, stt_deepgram]) tts_cartesia = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) tts_deepgram = DeepgramTTSService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], settings=DeepgramTTSService.Settings( voice="aura-2-helena-en", ), @@ -117,11 +117,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): system_prompt = "You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way." llm_openai = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings(system_instruction=system_prompt), ) llm_google = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings(system_instruction=system_prompt), ) # Uses ServiceSwitcherStrategyManual by default diff --git a/examples/features/features-switch-languages.py b/examples/features/features-switch-languages.py index c47d66847..f99de0aec 100644 --- a/examples/features/features-switch-languages.py +++ b/examples/features/features-switch-languages.py @@ -42,14 +42,14 @@ class SwitchLanguage(ParallelPipeline): self._current_language = "English" english_tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) spanish_tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="d4db5fb9-f44b-4bd1-85fa-192e0f0d75f9", # Spanish-speaking Lady ), @@ -101,7 +101,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = DeepgramSTTService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], settings=DeepgramSTTService.Settings( language="multi", ), @@ -110,7 +110,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tts = SwitchLanguage() llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You can speak the following languages: 'English' and 'Spanish'.", ), diff --git a/examples/features/features-switch-voices.py b/examples/features/features-switch-voices.py index 0c47d69ae..d33a10e8f 100644 --- a/examples/features/features-switch-voices.py +++ b/examples/features/features-switch-voices.py @@ -42,21 +42,21 @@ class SwitchVoices(ParallelPipeline): self._current_voice = "News Lady" news_lady = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="bf991597-6c13-47e4-8411-91ec2de5c466", # Newslady ), ) british_lady = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) barbershop_man = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="a0e99841-438c-4a64-b679-ae501e7d6091", # Barbershop Man ), @@ -114,12 +114,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = SwitchVoices() llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative and helpful way. You can do the following voices: 'News Lady', 'British Lady' and 'Barbershop Man'.", ), diff --git a/examples/features/features-user-email-gathering.py b/examples/features/features-user-email-gathering.py index 7e8a69011..f0ec3160f 100644 --- a/examples/features/features-user-email-gathering.py +++ b/examples/features/features-user-email-gathering.py @@ -60,13 +60,13 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) # Cartesia offers a `` tags that we can use to ask the user # to confirm the emails. # (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"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -84,7 +84,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You need to gather a valid email or emails from the user. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. If the user provides one or more email addresses confirm them with the user. Enclose all emails with tags, for example a@a.com.", ), diff --git a/examples/features/features-voicemail-detection.py b/examples/features/features-voicemail-detection.py index 854e546ec..4c8f07d6e 100644 --- a/examples/features/features-voicemail-detection.py +++ b/examples/features/features-voicemail-detection.py @@ -52,22 +52,22 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), ) - classifier_llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) + classifier_llm = OpenAILLMService(api_key=os.environ["OPENAI_API_KEY"]) voicemail = VoicemailDetector(llm=classifier_llm) diff --git a/examples/features/features-wake-phrase.py b/examples/features/features-wake-phrase.py index 50f8b1fb8..8d39d5c60 100644 --- a/examples/features/features-wake-phrase.py +++ b/examples/features/features-wake-phrase.py @@ -57,21 +57,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = DeepgramSTTService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], settings=DeepgramSTTService.Settings( keyterm=["pipecat"], ), ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-anthropic-async-stream.py b/examples/function-calling/function-calling-anthropic-async-stream.py index 52069af68..b44bb5997 100644 --- a/examples/function-calling/function-calling-anthropic-async-stream.py +++ b/examples/function-calling/function-calling-anthropic-async-stream.py @@ -107,17 +107,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), + api_key=os.environ["ANTHROPIC_API_KEY"], enable_async_tool_cancellation=True, settings=AnthropicLLMService.Settings( system_instruction=( diff --git a/examples/function-calling/function-calling-anthropic-async.py b/examples/function-calling/function-calling-anthropic-async.py index 2c5fb9402..5046ec839 100644 --- a/examples/function-calling/function-calling-anthropic-async.py +++ b/examples/function-calling/function-calling-anthropic-async.py @@ -66,17 +66,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), + api_key=os.environ["ANTHROPIC_API_KEY"], enable_async_tool_cancellation=True, settings=AnthropicLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/function-calling/function-calling-anthropic-video.py b/examples/function-calling/function-calling-anthropic-video.py index c3a292f31..1b7617950 100644 --- a/examples/function-calling/function-calling-anthropic-video.py +++ b/examples/function-calling/function-calling-anthropic-video.py @@ -86,10 +86,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -97,7 +97,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Anthropic for vision analysis llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), + api_key=os.environ["ANTHROPIC_API_KEY"], settings=AnthropicLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You are able to describe images from the user camera.", ), diff --git a/examples/function-calling/function-calling-anthropic.py b/examples/function-calling/function-calling-anthropic.py index b8bb4eac6..3c4cf769a 100644 --- a/examples/function-calling/function-calling-anthropic.py +++ b/examples/function-calling/function-calling-anthropic.py @@ -65,17 +65,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), + api_key=os.environ["ANTHROPIC_API_KEY"], settings=AnthropicLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-aws-video.py b/examples/function-calling/function-calling-aws-video.py index 8db25671b..d6ae64438 100644 --- a/examples/function-calling/function-calling-aws-video.py +++ b/examples/function-calling/function-calling-aws-video.py @@ -86,10 +86,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/function-calling/function-calling-azure.py b/examples/function-calling/function-calling-azure.py index 23c156da4..37d67b29b 100644 --- a/examples/function-calling/function-calling-azure.py +++ b/examples/function-calling/function-calling-azure.py @@ -60,18 +60,18 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( 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"), + api_key=os.environ["AZURE_CHATGPT_API_KEY"], + endpoint=os.environ["AZURE_CHATGPT_ENDPOINT"], settings=AzureLLMService.Settings( model=os.getenv("AZURE_CHATGPT_MODEL"), system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/function-calling/function-calling-cerebras.py b/examples/function-calling/function-calling-cerebras.py index ad8475185..82d98d40e 100644 --- a/examples/function-calling/function-calling-cerebras.py +++ b/examples/function-calling/function-calling-cerebras.py @@ -60,17 +60,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = CerebrasLLMService( - api_key=os.getenv("CEREBRAS_API_KEY"), + api_key=os.environ["CEREBRAS_API_KEY"], settings=CerebrasLLMService.Settings( system_instruction="""You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. diff --git a/examples/function-calling/function-calling-deepseek.py b/examples/function-calling/function-calling-deepseek.py index f115299e2..fc354ccf5 100644 --- a/examples/function-calling/function-calling-deepseek.py +++ b/examples/function-calling/function-calling-deepseek.py @@ -60,17 +60,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = DeepSeekLLMService( - api_key=os.getenv("DEEPSEEK_API_KEY"), + api_key=os.environ["DEEPSEEK_API_KEY"], settings=DeepSeekLLMService.Settings( model="deepseek-chat", system_instruction="""You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. diff --git a/examples/function-calling/function-calling-direct.py b/examples/function-calling/function-calling-direct.py index 1c6ebe072..c885d6606 100644 --- a/examples/function-calling/function-calling-direct.py +++ b/examples/function-calling/function-calling-direct.py @@ -76,17 +76,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-fireworks.py b/examples/function-calling/function-calling-fireworks.py index 6ddb85981..8c681fa72 100644 --- a/examples/function-calling/function-calling-fireworks.py +++ b/examples/function-calling/function-calling-fireworks.py @@ -60,17 +60,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = FireworksLLMService( - api_key=os.getenv("FIREWORKS_API_KEY"), + api_key=os.environ["FIREWORKS_API_KEY"], settings=FireworksLLMService.Settings( model="accounts/fireworks/models/gpt-oss-20b", system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/function-calling/function-calling-google-async-stream.py b/examples/function-calling/function-calling-google-async-stream.py index 503880ca6..1660442b4 100644 --- a/examples/function-calling/function-calling-google-async-stream.py +++ b/examples/function-calling/function-calling-google-async-stream.py @@ -107,17 +107,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], enable_async_tool_cancellation=True, settings=GoogleLLMService.Settings( system_instruction=( diff --git a/examples/function-calling/function-calling-google-async.py b/examples/function-calling/function-calling-google-async.py index dbc86d664..f3c5fbc1d 100644 --- a/examples/function-calling/function-calling-google-async.py +++ b/examples/function-calling/function-calling-google-async.py @@ -98,10 +98,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -127,7 +127,7 @@ indicate you should use the get_image tool are: """ llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], enable_async_tool_cancellation=True, settings=GoogleLLMService.Settings( system_instruction=system_prompt, diff --git a/examples/function-calling/function-calling-google-vertex.py b/examples/function-calling/function-calling-google-vertex.py index 3bee2f1bb..290315f2c 100644 --- a/examples/function-calling/function-calling-google-vertex.py +++ b/examples/function-calling/function-calling-google-vertex.py @@ -60,19 +60,19 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = ElevenLabsTTSService( - api_key=os.getenv("ELEVENLABS_API_KEY", ""), + api_key=os.environ["ELEVENLABS_API_KEY"], settings=ElevenLabsTTSService.Settings( - voice=os.getenv("ELEVENLABS_VOICE_ID", ""), + voice=os.getenv("ELEVENLABS_VOICE_ID", "Xb7hH8MSUJpSbSDYk0k2"), ), ) llm = GoogleVertexLLMService( - credentials=os.getenv("GOOGLE_VERTEX_TEST_CREDENTIALS"), - project_id=os.getenv("GOOGLE_CLOUD_PROJECT_ID"), - location=os.getenv("GOOGLE_CLOUD_LOCATION"), + credentials=os.environ["GOOGLE_VERTEX_TEST_CREDENTIALS"], + project_id=os.environ["GOOGLE_CLOUD_PROJECT_ID"], + location=os.environ["GOOGLE_CLOUD_LOCATION"], settings=GoogleVertexLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), @@ -103,14 +103,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tools = ToolsSchema(standard_tools=[weather_function]) - messages = [ - { - "role": "developer", - "content": "Start a conversation with 'Hey there' to get the current weather.", - }, - ] - - context = LLMContext(messages, tools) + context = LLMContext(tools=tools) user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), @@ -141,6 +134,12 @@ 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. + context.add_message( + { + "role": "developer", + "content": "Please introduce yourself to the user.", + } + ) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/function-calling/function-calling-google-video.py b/examples/function-calling/function-calling-google-video.py index 59816fdd5..65296c603 100644 --- a/examples/function-calling/function-calling-google-video.py +++ b/examples/function-calling/function-calling-google-video.py @@ -86,10 +86,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -97,7 +97,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Google Gemini model for vision analysis llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You are able to describe images from the user camera.", ), diff --git a/examples/function-calling/function-calling-google.py b/examples/function-calling/function-calling-google.py index 421a02a1e..1b6d5b152 100644 --- a/examples/function-calling/function-calling-google.py +++ b/examples/function-calling/function-calling-google.py @@ -96,10 +96,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -125,7 +125,7 @@ indicate you should use the get_image tool are: """ llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( system_instruction=system_prompt, ), diff --git a/examples/function-calling/function-calling-grok.py b/examples/function-calling/function-calling-grok.py index 05e1efaf9..537ab2025 100644 --- a/examples/function-calling/function-calling-grok.py +++ b/examples/function-calling/function-calling-grok.py @@ -62,10 +62,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = XAIHttpTTSService( - api_key=os.getenv("XAI_API_KEY"), + api_key=os.environ["XAI_API_KEY"], aiohttp_session=session, settings=XAIHttpTTSService.Settings( voice="eve", @@ -73,7 +73,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = GrokLLMService( - api_key=os.getenv("XAI_API_KEY"), + api_key=os.environ["XAI_API_KEY"], settings=GrokLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-groq.py b/examples/function-calling/function-calling-groq.py index 1e6e84338..d4c69349e 100644 --- a/examples/function-calling/function-calling-groq.py +++ b/examples/function-calling/function-calling-groq.py @@ -60,17 +60,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = GroqSTTService(api_key=os.getenv("GROQ_API_KEY")) + stt = GroqSTTService(api_key=os.environ["GROQ_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = GroqLLMService( - api_key=os.getenv("GROQ_API_KEY"), + api_key=os.environ["GROQ_API_KEY"], settings=GroqLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-mistral.py b/examples/function-calling/function-calling-mistral.py index c52d46c03..e44adf8ba 100644 --- a/examples/function-calling/function-calling-mistral.py +++ b/examples/function-calling/function-calling-mistral.py @@ -63,17 +63,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = MistralLLMService( - api_key=os.getenv("MISTRAL_API_KEY"), + api_key=os.environ["MISTRAL_API_KEY"], settings=MistralLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-moondream-video.py b/examples/function-calling/function-calling-moondream-video.py index b8076e7ce..56a0fa503 100644 --- a/examples/function-calling/function-calling-moondream-video.py +++ b/examples/function-calling/function-calling-moondream-video.py @@ -117,17 +117,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You are able to describe images from the user camera.", ), diff --git a/examples/function-calling/function-calling-nebius.py b/examples/function-calling/function-calling-nebius.py index 4fe9a378a..ed8fded2c 100644 --- a/examples/function-calling/function-calling-nebius.py +++ b/examples/function-calling/function-calling-nebius.py @@ -63,17 +63,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = NebiusLLMService( - api_key=os.getenv("NEBIUS_API_KEY"), + api_key=os.environ["NEBIUS_API_KEY"], settings=NebiusLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-novita.py b/examples/function-calling/function-calling-novita.py index da60d890b..d9838e37f 100644 --- a/examples/function-calling/function-calling-novita.py +++ b/examples/function-calling/function-calling-novita.py @@ -63,17 +63,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = NovitaLLMService( - api_key=os.getenv("NOVITA_API_KEY"), + api_key=os.environ["NOVITA_API_KEY"], settings=NovitaLLMService.Settings( model="openai/gpt-oss-120b", system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/function-calling/function-calling-nvidia.py b/examples/function-calling/function-calling-nvidia.py index e3db6db8d..2b4818ceb 100644 --- a/examples/function-calling/function-calling-nvidia.py +++ b/examples/function-calling/function-calling-nvidia.py @@ -60,17 +60,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = NvidiaLLMService( - api_key=os.getenv("NVIDIA_API_KEY"), + api_key=os.environ["NVIDIA_API_KEY"], settings=NvidiaLLMService.Settings( model="nvidia/llama-3.3-nemotron-super-49b-v1.5", # Recommended when turning thinking off diff --git a/examples/function-calling/function-calling-ollama.py b/examples/function-calling/function-calling-ollama.py index 87491f3d6..ec6c3948a 100644 --- a/examples/function-calling/function-calling-ollama.py +++ b/examples/function-calling/function-calling-ollama.py @@ -64,10 +64,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/function-calling/function-calling-openai-async-stream.py b/examples/function-calling/function-calling-openai-async-stream.py index a60a5198f..b1d9d724b 100644 --- a/examples/function-calling/function-calling-openai-async-stream.py +++ b/examples/function-calling/function-calling-openai-async-stream.py @@ -107,17 +107,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], enable_async_tool_cancellation=True, settings=OpenAILLMService.Settings( system_instruction=( diff --git a/examples/function-calling/function-calling-openai-async.py b/examples/function-calling/function-calling-openai-async.py index 31c932d5f..47039711f 100644 --- a/examples/function-calling/function-calling-openai-async.py +++ b/examples/function-calling/function-calling-openai-async.py @@ -70,7 +70,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = OpenAISTTService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAISTTService.Settings( model="gpt-4o-transcribe", prompt="Expect words related weather, such as temperature and conditions. And restaurant names.", @@ -78,7 +78,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = OpenAITTSService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAITTSService.Settings( voice="ballad", ), @@ -86,7 +86,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], enable_async_tool_cancellation=True, settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/function-calling/function-calling-openai-responses-async-stream.py b/examples/function-calling/function-calling-openai-responses-async-stream.py index 745c18ae1..4007c21eb 100644 --- a/examples/function-calling/function-calling-openai-responses-async-stream.py +++ b/examples/function-calling/function-calling-openai-responses-async-stream.py @@ -107,17 +107,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], enable_async_tool_cancellation=True, settings=OpenAIResponsesLLMService.Settings( system_instruction=( diff --git a/examples/function-calling/function-calling-openai-responses-async.py b/examples/function-calling/function-calling-openai-responses-async.py index 368f41fe1..f7e6d370b 100644 --- a/examples/function-calling/function-calling-openai-responses-async.py +++ b/examples/function-calling/function-calling-openai-responses-async.py @@ -66,17 +66,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], enable_async_tool_cancellation=True, settings=OpenAIResponsesLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/function-calling/function-calling-openai-responses-http.py b/examples/function-calling/function-calling-openai-responses-http.py index ae38c98f5..e27d5d82b 100644 --- a/examples/function-calling/function-calling-openai-responses-http.py +++ b/examples/function-calling/function-calling-openai-responses-http.py @@ -63,17 +63,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesHttpLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIResponsesHttpLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-openai-responses-video-http.py b/examples/function-calling/function-calling-openai-responses-video-http.py index ad83aab24..9d9953359 100644 --- a/examples/function-calling/function-calling-openai-responses-video-http.py +++ b/examples/function-calling/function-calling-openai-responses-video-http.py @@ -87,17 +87,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesHttpLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIResponsesHttpLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You are able to describe images from the user camera.", ), diff --git a/examples/function-calling/function-calling-openai-responses-video.py b/examples/function-calling/function-calling-openai-responses-video.py index 9a77af400..3cb159a3f 100644 --- a/examples/function-calling/function-calling-openai-responses-video.py +++ b/examples/function-calling/function-calling-openai-responses-video.py @@ -87,17 +87,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIResponsesLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You are able to describe images from the user camera.", ), diff --git a/examples/function-calling/function-calling-openai-responses.py b/examples/function-calling/function-calling-openai-responses.py index 171e7b36e..97481d01e 100644 --- a/examples/function-calling/function-calling-openai-responses.py +++ b/examples/function-calling/function-calling-openai-responses.py @@ -63,17 +63,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIResponsesLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-openai-video.py b/examples/function-calling/function-calling-openai-video.py index 3c4fcd2f6..8ca7725b0 100644 --- a/examples/function-calling/function-calling-openai-video.py +++ b/examples/function-calling/function-calling-openai-video.py @@ -87,17 +87,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You are able to describe images from the user camera.", ), diff --git a/examples/function-calling/function-calling-openai.py b/examples/function-calling/function-calling-openai.py index 2b59d7072..2a9779742 100644 --- a/examples/function-calling/function-calling-openai.py +++ b/examples/function-calling/function-calling-openai.py @@ -64,7 +64,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = OpenAISTTService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAISTTService.Settings( model="gpt-4o-transcribe", prompt="Expect words related weather, such as temperature and conditions. And restaurant names.", @@ -72,7 +72,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = OpenAITTSService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAITTSService.Settings( voice="ballad", ), @@ -80,7 +80,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-openrouter.py b/examples/function-calling/function-calling-openrouter.py index b341ca71c..299846133 100644 --- a/examples/function-calling/function-calling-openrouter.py +++ b/examples/function-calling/function-calling-openrouter.py @@ -60,11 +60,11 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = AzureTTSService( - api_key=os.getenv("AZURE_SPEECH_API_KEY"), - region=os.getenv("AZURE_SPEECH_REGION"), + api_key=os.environ["AZURE_SPEECH_API_KEY"], + region=os.environ["AZURE_SPEECH_REGION"], settings=AzureTTSService.Settings( voice="en-US-JennyNeural", language="en-US", @@ -74,7 +74,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenRouterLLMService( - api_key=os.getenv("OPENROUTER_API_KEY"), + api_key=os.environ["OPENROUTER_API_KEY"], settings=OpenRouterLLMService.Settings( model="openai/gpt-4o-2024-11-20", system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/function-calling/function-calling-perplexity.py b/examples/function-calling/function-calling-perplexity.py index 0fa3ff928..8abbc3618 100644 --- a/examples/function-calling/function-calling-perplexity.py +++ b/examples/function-calling/function-calling-perplexity.py @@ -58,17 +58,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = PerplexityLLMService( - api_key=os.getenv("PERPLEXITY_API_KEY"), + api_key=os.environ["PERPLEXITY_API_KEY"], settings=PerplexityLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-qwen.py b/examples/function-calling/function-calling-qwen.py index 9a6bf6d8b..0bbb7311d 100644 --- a/examples/function-calling/function-calling-qwen.py +++ b/examples/function-calling/function-calling-qwen.py @@ -60,17 +60,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = QwenLLMService( - api_key=os.getenv("QWEN_API_KEY"), + api_key=os.environ["QWEN_API_KEY"], model="qwen2.5-72b-instruct", settings=QwenLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/function-calling/function-calling-sambanova.py b/examples/function-calling/function-calling-sambanova.py index c1e880bc0..528c4fc47 100644 --- a/examples/function-calling/function-calling-sambanova.py +++ b/examples/function-calling/function-calling-sambanova.py @@ -61,18 +61,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = DeepgramSTTService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = SambaNovaLLMService( - api_key=os.getenv("SAMBANOVA_API_KEY"), + api_key=os.environ["SAMBANOVA_API_KEY"], settings=SambaNovaLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-sarvam.py b/examples/function-calling/function-calling-sarvam.py index bd3fa42fb..830860a9a 100644 --- a/examples/function-calling/function-calling-sarvam.py +++ b/examples/function-calling/function-calling-sarvam.py @@ -64,21 +64,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = SarvamSTTService( - api_key=os.getenv("SARVAM_API_KEY"), + api_key=os.environ["SARVAM_API_KEY"], settings=SarvamSTTService.Settings( model="saaras:v3", ), ) tts = SarvamTTSService( - api_key=os.getenv("SARVAM_API_KEY"), + api_key=os.environ["SARVAM_API_KEY"], settings=SarvamTTSService.Settings( model="bulbul:v3", voice="shubh", ), ) llm = SarvamLLMService( - api_key=os.getenv("SARVAM_API_KEY"), + api_key=os.environ["SARVAM_API_KEY"], settings=SarvamLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/function-calling/function-calling-together.py b/examples/function-calling/function-calling-together.py index 78da7fbe9..e785588f4 100644 --- a/examples/function-calling/function-calling-together.py +++ b/examples/function-calling/function-calling-together.py @@ -60,17 +60,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = TogetherLLMService( - api_key=os.getenv("TOGETHER_API_KEY"), + api_key=os.environ["TOGETHER_API_KEY"], settings=TogetherLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/getting-started/01-say-one-thing.py b/examples/getting-started/01-say-one-thing.py index fdfecde6c..1c6e1c703 100644 --- a/examples/getting-started/01-say-one-thing.py +++ b/examples/getting-started/01-say-one-thing.py @@ -36,7 +36,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/getting-started/01a-local-audio.py b/examples/getting-started/01a-local-audio.py index 1e18b4b03..02a489c93 100644 --- a/examples/getting-started/01a-local-audio.py +++ b/examples/getting-started/01a-local-audio.py @@ -28,7 +28,7 @@ async def main(): transport = LocalAudioTransport(LocalAudioTransportParams(audio_out_enabled=True)) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/getting-started/02-llm-say-one-thing.py b/examples/getting-started/02-llm-say-one-thing.py index 74809ed2a..df52772cf 100644 --- a/examples/getting-started/02-llm-say-one-thing.py +++ b/examples/getting-started/02-llm-say-one-thing.py @@ -38,14 +38,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/getting-started/03-still-frame.py b/examples/getting-started/03-still-frame.py index 259072959..61b211499 100644 --- a/examples/getting-started/03-still-frame.py +++ b/examples/getting-started/03-still-frame.py @@ -42,7 +42,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") imagegen = GoogleImageGenService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], ) task = PipelineTask( diff --git a/examples/getting-started/04-sync-speech-and-image.py b/examples/getting-started/04-sync-speech-and-image.py index f0e2ff9c7..c26bb324e 100644 --- a/examples/getting-started/04-sync-speech-and-image.py +++ b/examples/getting-started/04-sync-speech-and-image.py @@ -108,10 +108,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create an HTTP session for API calls async with aiohttp.ClientSession() as session: - llm = OpenAILLMService(api_key=os.getenv("OPENAI_API_KEY")) + llm = OpenAILLMService(api_key=os.environ["OPENAI_API_KEY"]) tts = CartesiaHttpTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaHttpTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/getting-started/05-speaking-state.py b/examples/getting-started/05-speaking-state.py index 36762f6b0..32206d1b0 100644 --- a/examples/getting-started/05-speaking-state.py +++ b/examples/getting-started/05-speaking-state.py @@ -96,17 +96,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/getting-started/06-voice-agent.py b/examples/getting-started/06-voice-agent.py index 057429589..c9fe1cf12 100644 --- a/examples/getting-started/06-voice-agent.py +++ b/examples/getting-started/06-voice-agent.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/getting-started/06a-voice-agent-local.py b/examples/getting-started/06a-voice-agent-local.py index 3d183b405..8864f7aff 100644 --- a/examples/getting-started/06a-voice-agent-local.py +++ b/examples/getting-started/06a-voice-agent-local.py @@ -40,17 +40,17 @@ async def main(): ) ) - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/getting-started/07-function-calling.py b/examples/getting-started/07-function-calling.py index 085937da9..173f6a6fe 100644 --- a/examples/getting-started/07-function-calling.py +++ b/examples/getting-started/07-function-calling.py @@ -63,17 +63,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/mcp/mcp-multiple-mcp.py b/examples/mcp/mcp-multiple-mcp.py index 7bdfa1343..8d7717291 100644 --- a/examples/mcp/mcp-multiple-mcp.py +++ b/examples/mcp/mcp-multiple-mcp.py @@ -53,10 +53,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -77,7 +77,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): """ llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), + api_key=os.environ["ANTHROPIC_API_KEY"], settings=AnthropicLLMService.Settings( system_instruction=system_prompt, ), diff --git a/examples/mcp/mcp-stdio.py b/examples/mcp/mcp-stdio.py index daae45c0c..a93463ede 100644 --- a/examples/mcp/mcp-stdio.py +++ b/examples/mcp/mcp-stdio.py @@ -49,10 +49,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -71,7 +71,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): """ llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), + api_key=os.environ["ANTHROPIC_API_KEY"], settings=AnthropicLLMService.Settings( system_instruction=system_prompt, ), diff --git a/examples/mcp/mcp-streamable-http-gemini-live.py b/examples/mcp/mcp-streamable-http-gemini-live.py index 8b824454f..213667e7a 100644 --- a/examples/mcp/mcp-streamable-http-gemini-live.py +++ b/examples/mcp/mcp-streamable-http-gemini-live.py @@ -23,8 +23,6 @@ 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.deepgram.stt import DeepgramSTTService from pipecat.services.google.gemini_live.llm import GeminiLiveLLMService from pipecat.services.mcp_service import MCPClient from pipecat.transports.base_transport import BaseTransport, TransportParams @@ -54,15 +52,6 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) - - tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), - settings=CartesiaTTSService.Settings( - voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady - ), - ) - system = f""" You are a helpful LLM in a voice call. Your goal is to answer questions about the user's GitHub repositories and account. @@ -85,7 +74,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): tools = await mcp.get_tools_schema() llm = GeminiLiveLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], system_instruction=system, tools=tools, ) diff --git a/examples/mcp/mcp-streamable-http.py b/examples/mcp/mcp-streamable-http.py index 59860d307..b4823c649 100644 --- a/examples/mcp/mcp-streamable-http.py +++ b/examples/mcp/mcp-streamable-http.py @@ -54,10 +54,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -73,7 +73,7 @@ Just respond with short sentences when you are carrying out tool calls. """ llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( system_instruction=system_prompt, ), diff --git a/examples/observability/observability-observer.py b/examples/observability/observability-observer.py index 457ba7bb4..4a1bbbbfa 100644 --- a/examples/observability/observability-observer.py +++ b/examples/observability/observability-observer.py @@ -100,17 +100,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/observability/observability-sentry-metrics.py b/examples/observability/observability-sentry-metrics.py index 3d4146150..9a8f8d553 100644 --- a/examples/observability/observability-sentry-metrics.py +++ b/examples/observability/observability-sentry-metrics.py @@ -60,12 +60,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) stt = DeepgramSTTService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], metrics=SentryMetrics(), ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -73,7 +73,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], metrics=SentryMetrics(), settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/persistent-context/persistent-context-anthropic.py b/examples/persistent-context/persistent-context-anthropic.py index 791f00440..cdddc9080 100644 --- a/examples/persistent-context/persistent-context-anthropic.py +++ b/examples/persistent-context/persistent-context-anthropic.py @@ -170,17 +170,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), + api_key=os.environ["ANTHROPIC_API_KEY"], settings=AnthropicLLMService.Settings( system_instruction=system_instruction, ), diff --git a/examples/persistent-context/persistent-context-aws-nova-sonic.py b/examples/persistent-context/persistent-context-aws-nova-sonic.py index 62b9e7eab..8a4b7ba47 100644 --- a/examples/persistent-context/persistent-context-aws-nova-sonic.py +++ b/examples/persistent-context/persistent-context-aws-nova-sonic.py @@ -87,7 +87,9 @@ async def save_conversation(params: FunctionCallParams): # the simplest thing to do is to pop messages until the last one is an assistant # response while messages and not ( - messages[-1].get("role") == "assistant" and "content" in messages[-1] + isinstance(messages[-1], dict) + and messages[-1].get("role") == "assistant" + and "content" in messages[-1] ): messages.pop() if messages: # we never expect this to be empty @@ -125,6 +127,7 @@ async def load_conversation(params: FunctionCallParams): } ) params.context.set_messages(messages) + assert isinstance(params.llm, AWSNovaSonicLLMService) await params.llm.reset_conversation() # await params.llm.trigger_assistant_response() except Exception as e: @@ -219,9 +222,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = AWSNovaSonicLLMService( - secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"), - access_key_id=os.getenv("AWS_ACCESS_KEY_ID"), - region=os.getenv("AWS_REGION"), # as of 2025-05-06, us-east-1 is the only supported region + secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"], + access_key_id=os.environ["AWS_ACCESS_KEY_ID"], + region=os.environ["AWS_REGION"], # as of 2025-05-06, us-east-1 is the only supported region settings=AWSNovaSonicLLMService.Settings( voice="tiffany", # matthew, tiffany, amy system_instruction=system_instruction, diff --git a/examples/persistent-context/persistent-context-gemini.py b/examples/persistent-context/persistent-context-gemini.py index 2ec3cd0bb..2ae43bf87 100644 --- a/examples/persistent-context/persistent-context-gemini.py +++ b/examples/persistent-context/persistent-context-gemini.py @@ -243,17 +243,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], system_instruction=system_instruction, ) diff --git a/examples/persistent-context/persistent-context-grok-realtime.py b/examples/persistent-context/persistent-context-grok-realtime.py index 4a990d24e..e21dbf1c3 100644 --- a/examples/persistent-context/persistent-context-grok-realtime.py +++ b/examples/persistent-context/persistent-context-grok-realtime.py @@ -192,7 +192,7 @@ Remember, your responses should be short - just one or two sentences usually.""" ) llm = GrokRealtimeLLMService( - api_key=os.getenv("XAI_API_KEY"), + api_key=os.environ["XAI_API_KEY"], session_properties=session_properties, ) diff --git a/examples/persistent-context/persistent-context-openai-realtime.py b/examples/persistent-context/persistent-context-openai-realtime.py index 0a7a888a8..067e1f73f 100644 --- a/examples/persistent-context/persistent-context-openai-realtime.py +++ b/examples/persistent-context/persistent-context-openai-realtime.py @@ -93,6 +93,7 @@ async def load_conversation(params: FunctionCallParams): try: with open(filename) as file: params.context.set_messages(json.load(file)) + assert isinstance(params.llm, OpenAIRealtimeLLMService) await params.llm.reset_conversation() # NOTE: we manually create a response here rather than relying # on the function callback to trigger one since we've reset the @@ -171,10 +172,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) llm = OpenAIRealtimeLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIRealtimeLLMService.Settings( system_instruction="""Your knowledge cutoff is 2023-10. You are a helpful and friendly AI. diff --git a/examples/persistent-context/persistent-context-openai-responses-http.py b/examples/persistent-context/persistent-context-openai-responses-http.py index d77513049..362fd86f6 100644 --- a/examples/persistent-context/persistent-context-openai-responses-http.py +++ b/examples/persistent-context/persistent-context-openai-responses-http.py @@ -171,17 +171,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesHttpLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIResponsesHttpLLMService.Settings( system_instruction=system_instruction, ), diff --git a/examples/persistent-context/persistent-context-openai-responses.py b/examples/persistent-context/persistent-context-openai-responses.py index c89fe3ff1..9c3f33c94 100644 --- a/examples/persistent-context/persistent-context-openai-responses.py +++ b/examples/persistent-context/persistent-context-openai-responses.py @@ -171,17 +171,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIResponsesLLMService.Settings( system_instruction=system_instruction, ), diff --git a/examples/persistent-context/persistent-context-openai.py b/examples/persistent-context/persistent-context-openai.py index 22e160102..fa29ad5c2 100644 --- a/examples/persistent-context/persistent-context-openai.py +++ b/examples/persistent-context/persistent-context-openai.py @@ -171,17 +171,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], system_instruction=system_instruction, ) diff --git a/examples/rag/rag-gemini-grounding-metadata.py b/examples/rag/rag-gemini-grounding-metadata.py index 5b706d6c9..cddefe591 100644 --- a/examples/rag/rag-gemini-grounding-metadata.py +++ b/examples/rag/rag-gemini-grounding-metadata.py @@ -95,10 +95,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -106,7 +106,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Initialize the Gemini Multimodal Live model llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( system_instruction=system_instruction, ), diff --git a/examples/rag/rag-gemini.py b/examples/rag/rag-gemini.py index 0f9a8ddb2..1567ad051 100644 --- a/examples/rag/rag-gemini.py +++ b/examples/rag/rag-gemini.py @@ -52,7 +52,7 @@ import os import time from dotenv import load_dotenv -from google import genai +from google import genai # pyright: ignore[reportAttributeAccessIssue] from loguru import logger from pipecat.adapters.schemas.function_schema import FunctionSchema @@ -179,10 +179,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="f9836c6e-a0bd-460e-9d3c-f7299fa60f94", # Southern Lady ), @@ -197,7 +197,7 @@ Your response will be turned into speech so use only simple words and punctuatio """ llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( model=VOICE_MODEL, system_instruction=system_prompt, diff --git a/examples/rag/rag-mem0.py b/examples/rag/rag-mem0.py index c7c0f13bd..1cbf97d14 100644 --- a/examples/rag/rag-mem0.py +++ b/examples/rag/rag-mem0.py @@ -133,11 +133,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) # Initialize text-to-speech service tts = ElevenLabsTTSService( - api_key=os.getenv("ELEVENLABS_API_KEY"), + api_key=os.environ["ELEVENLABS_API_KEY"], settings=ElevenLabsTTSService.Settings( voice="pNInz6obpgDQGcFmaJgB", ), @@ -196,7 +196,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Initialize LLM service llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="""You are a personal assistant. You can remember things about the person you are talking to. Some Guidelines: diff --git a/examples/realtime/realtime-aws-nova-sonic.py b/examples/realtime/realtime-aws-nova-sonic.py index f3a1a0737..5e6a2037c 100644 --- a/examples/realtime/realtime-aws-nova-sonic.py +++ b/examples/realtime/realtime-aws-nova-sonic.py @@ -116,8 +116,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create the AWS Nova Sonic LLM service llm = AWSNovaSonicLLMService( - secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"), - access_key_id=os.getenv("AWS_ACCESS_KEY_ID"), + secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"], + access_key_id=os.environ["AWS_ACCESS_KEY_ID"], # as of 2025-12-09, these are the supported regions: # - Nova 2 Sonic (the default model): # - us-east-1 @@ -126,7 +126,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # - Nova Sonic (the older model): # - us-east-1 # - ap-northeast-1 - region=os.getenv("AWS_REGION"), + region=os.environ["AWS_REGION"], session_token=os.getenv("AWS_SESSION_TOKEN"), settings=AWSNovaSonicLLMService.Settings( voice="tiffany", diff --git a/examples/realtime/realtime-azure.py b/examples/realtime/realtime-azure.py index c57602f6f..c4ff80dcb 100644 --- a/examples/realtime/realtime-azure.py +++ b/examples/realtime/realtime-azure.py @@ -112,8 +112,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") llm = AzureRealtimeLLMService( - api_key=os.getenv("AZURE_REALTIME_API_KEY"), - base_url=os.getenv("AZURE_REALTIME_BASE_URL"), + api_key=os.environ["AZURE_REALTIME_API_KEY"], + base_url=os.environ["AZURE_REALTIME_BASE_URL"], settings=AzureRealtimeLLMService.Settings( system_instruction="""You are a helpful and friendly AI. diff --git a/examples/realtime/realtime-gemini-live-files-api.py b/examples/realtime/realtime-gemini-live-files-api.py index 1871bb5bf..99f35d52a 100644 --- a/examples/realtime/realtime-gemini-live-files-api.py +++ b/examples/realtime/realtime-gemini-live-files-api.py @@ -104,7 +104,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Initialize Gemini service with File API support llm = GeminiLiveLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GeminiLiveLLMService.Settings( system_instruction=system_instruction, voice="Charon", # Aoede, Charon, Fenrir, Kore, Puck diff --git a/examples/realtime/realtime-gemini-live-function-calling.py b/examples/realtime/realtime-gemini-live-function-calling.py index a370fdf57..d038a5c4f 100644 --- a/examples/realtime/realtime-gemini-live-function-calling.py +++ b/examples/realtime/realtime-gemini-live-function-calling.py @@ -114,7 +114,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = GeminiLiveLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GeminiLiveLLMService.Settings( system_instruction=system_instruction, ), diff --git a/examples/realtime/realtime-gemini-live-google-search.py b/examples/realtime/realtime-gemini-live-google-search.py index 7822bb085..6b132cef1 100644 --- a/examples/realtime/realtime-gemini-live-google-search.py +++ b/examples/realtime/realtime-gemini-live-google-search.py @@ -67,7 +67,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Initialize the Gemini Multimodal Live model llm = GeminiLiveLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GeminiLiveLLMService.Settings( voice="Puck", # Aoede, Charon, Fenrir, Kore, Puck system_instruction=system_instruction, diff --git a/examples/realtime/realtime-gemini-live-graceful-end.py b/examples/realtime/realtime-gemini-live-graceful-end.py index 7eca04fb3..d65414022 100644 --- a/examples/realtime/realtime-gemini-live-graceful-end.py +++ b/examples/realtime/realtime-gemini-live-graceful-end.py @@ -133,7 +133,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = GeminiLiveLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GeminiLiveLLMService.Settings( system_instruction=system_instruction, ), diff --git a/examples/realtime/realtime-gemini-live-grounding-metadata.py b/examples/realtime/realtime-gemini-live-grounding-metadata.py index 31fd7d832..e78d5cffa 100644 --- a/examples/realtime/realtime-gemini-live-grounding-metadata.py +++ b/examples/realtime/realtime-gemini-live-grounding-metadata.py @@ -75,7 +75,8 @@ class GroundingMetadataProcessor(FrameProcessor): if isinstance(frame, LLMSearchResponseFrame): self._grounding_count += 1 logger.info(f"\n\n🔍 GROUNDING METADATA RECEIVED #{self._grounding_count}\n") - logger.info(f"📝 Search Result Text: {frame.search_result[:200]}...") + if frame.search_result: + logger.info(f"📝 Search Result Text: {frame.search_result[:200]}...") if frame.rendered_content: logger.info(f"🔗 Rendered Content: {frame.rendered_content}") @@ -101,7 +102,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = GeminiLiveLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GeminiLiveLLMService.Settings( system_instruction=SYSTEM_INSTRUCTION, voice="Charon", # Aoede, Charon, Fenrir, Kore, Puck @@ -111,16 +112,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create a processor to capture grounding metadata grounding_processor = GroundingMetadataProcessor() - - messages = [ - { - "role": "user", - "content": "Please introduce yourself and let me know that you can help with current information by searching the web. Ask me what current information I'd like to know about.", - }, - ] - # Set up conversation context and management - context = LLMContext(messages) + context = LLMContext() # Server-side VAD is enabled by default; no local VAD is added. user_aggregator, assistant_aggregator = LLMContextAggregatorPair(context) @@ -144,6 +137,12 @@ 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. + context.add_message( + { + "role": "developer", + "content": "Please introduce yourself and let me know that you can help with current information by searching the web. Ask me what current information I'd like to know about.", + } + ) await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") diff --git a/examples/realtime/realtime-gemini-live-local-vad.py b/examples/realtime/realtime-gemini-live-local-vad.py index 7a73742e9..c7580f0c6 100644 --- a/examples/realtime/realtime-gemini-live-local-vad.py +++ b/examples/realtime/realtime-gemini-live-local-vad.py @@ -54,7 +54,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") llm = GeminiLiveLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GeminiLiveLLMService.Settings( voice="Aoede", # Puck, Charon, Kore, Fenrir, Aoede vad=GeminiVADParams(disabled=True), diff --git a/examples/realtime/realtime-gemini-live-vertex-function-calling.py b/examples/realtime/realtime-gemini-live-vertex-function-calling.py index 68add5bc9..2c0861006 100644 --- a/examples/realtime/realtime-gemini-live-vertex-function-calling.py +++ b/examples/realtime/realtime-gemini-live-vertex-function-calling.py @@ -110,8 +110,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GeminiLiveVertexLLMService( credentials=os.getenv("GOOGLE_VERTEX_TEST_CREDENTIALS"), - project_id=os.getenv("GOOGLE_CLOUD_PROJECT_ID"), - location=os.getenv("GOOGLE_CLOUD_LOCATION"), + project_id=os.environ["GOOGLE_CLOUD_PROJECT_ID"], + location=os.environ["GOOGLE_CLOUD_LOCATION"], settings=GeminiLiveVertexLLMService.Settings( system_instruction=system_instruction, voice="Puck", # Aoede, Charon, Fenrir, Kore, Puck diff --git a/examples/realtime/realtime-gemini-live-video.py b/examples/realtime/realtime-gemini-live-video.py index 269f22718..4319b534a 100644 --- a/examples/realtime/realtime-gemini-live-video.py +++ b/examples/realtime/realtime-gemini-live-video.py @@ -47,7 +47,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GeminiLiveLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GeminiLiveLLMService.Settings( voice="Aoede", # Puck, Charon, Kore, Fenrir, Aoede # system_instruction="Talk like a pirate." diff --git a/examples/realtime/realtime-gemini-live.py b/examples/realtime/realtime-gemini-live.py index dc9e8e55a..04fa9c625 100644 --- a/examples/realtime/realtime-gemini-live.py +++ b/examples/realtime/realtime-gemini-live.py @@ -52,7 +52,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") llm = GeminiLiveLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GeminiLiveLLMService.Settings( voice="Aoede", # Puck, Charon, Kore, Fenrir, Aoede # system_instruction="Talk like a pirate." diff --git a/examples/realtime/realtime-grok.py b/examples/realtime/realtime-grok.py index 3f1543871..1e122865a 100644 --- a/examples/realtime/realtime-grok.py +++ b/examples/realtime/realtime-grok.py @@ -179,7 +179,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create the Grok Realtime LLM service llm = GrokRealtimeLLMService( - api_key=os.getenv("XAI_API_KEY"), + api_key=os.environ["XAI_API_KEY"], settings=GrokRealtimeLLMService.Settings( system_instruction="""You are a helpful and friendly AI assistant powered by Grok. diff --git a/examples/realtime/realtime-inworld.py b/examples/realtime/realtime-inworld.py index 67bed6df9..76defbc24 100644 --- a/examples/realtime/realtime-inworld.py +++ b/examples/realtime/realtime-inworld.py @@ -84,7 +84,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # llm_model can be any supported model or an Inworld Router. # See: https://docs.inworld.ai/router/introduction llm = InworldRealtimeLLMService( - api_key=os.getenv("INWORLD_API_KEY"), + api_key=os.environ["INWORLD_API_KEY"], llm_model="xai/grok-4-1-fast-non-reasoning", voice="Sarah", settings=InworldRealtimeLLMService.Settings( diff --git a/examples/realtime/realtime-openai-live-video.py b/examples/realtime/realtime-openai-live-video.py index fdf7c04e8..b35aa2648 100644 --- a/examples/realtime/realtime-openai-live-video.py +++ b/examples/realtime/realtime-openai-live-video.py @@ -62,7 +62,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") llm = OpenAIRealtimeLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIRealtimeLLMService.Settings( system_instruction="""You are a helpful and friendly AI. @@ -133,8 +133,8 @@ Remember, your responses should be short. Just one or two sentences, usually. Re async def on_client_connected(transport, client): logger.info(f"Client connected: {client}") - await maybe_capture_participant_camera(transport, client, framerate=0.5) - await maybe_capture_participant_screen(transport, client, framerate=0.5) + await maybe_capture_participant_camera(transport, client, framerate=1) + await maybe_capture_participant_screen(transport, client, framerate=1) await task.queue_frames([LLMRunFrame()]) diff --git a/examples/realtime/realtime-openai-text.py b/examples/realtime/realtime-openai-text.py index 4147ca4c3..f36a3c773 100644 --- a/examples/realtime/realtime-openai-text.py +++ b/examples/realtime/realtime-openai-text.py @@ -117,7 +117,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") llm = OpenAIRealtimeLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIRealtimeLLMSettings( system_instruction="""You are a helpful and friendly AI. @@ -156,7 +156,7 @@ Remember, your responses should be short. Just one or two sentences, usually. Re ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/realtime/realtime-openai.py b/examples/realtime/realtime-openai.py index 9c47bac77..6f347ed9b 100644 --- a/examples/realtime/realtime-openai.py +++ b/examples/realtime/realtime-openai.py @@ -136,7 +136,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") llm = OpenAIRealtimeLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIRealtimeLLMService.Settings( system_instruction="""You are a helpful and friendly AI. diff --git a/examples/realtime/realtime-ultravox-text.py b/examples/realtime/realtime-ultravox-text.py index 8b876048a..a144af919 100644 --- a/examples/realtime/realtime-ultravox-text.py +++ b/examples/realtime/realtime-ultravox-text.py @@ -168,7 +168,7 @@ There is also a secret menu that changes daily. If the user asks about it, use t llm = UltravoxRealtimeLLMService( params=OneShotInputParams( - api_key=os.getenv("ULTRAVOX_API_KEY"), + api_key=os.environ["ULTRAVOX_API_KEY"], system_prompt=system_prompt, temperature=0.3, max_duration=datetime.timedelta(minutes=3), diff --git a/examples/realtime/realtime-ultravox.py b/examples/realtime/realtime-ultravox.py index 7aaacdeaf..ed46aba2f 100644 --- a/examples/realtime/realtime-ultravox.py +++ b/examples/realtime/realtime-ultravox.py @@ -166,7 +166,7 @@ There is also a secret menu that changes daily. If the user asks about it, use t llm = UltravoxRealtimeLLMService( params=OneShotInputParams( - api_key=os.getenv("ULTRAVOX_API_KEY"), + api_key=os.environ["ULTRAVOX_API_KEY"], system_prompt=system_prompt, temperature=0.3, max_duration=datetime.timedelta(minutes=3), diff --git a/examples/thinking/thinking-anthropic.py b/examples/thinking/thinking-anthropic.py index 0cd768925..fe64aa3f3 100644 --- a/examples/thinking/thinking-anthropic.py +++ b/examples/thinking/thinking-anthropic.py @@ -52,17 +52,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), + api_key=os.environ["ANTHROPIC_API_KEY"], settings=AnthropicLLMService.Settings( thinking=AnthropicLLMService.ThinkingConfig( type="enabled", diff --git a/examples/thinking/thinking-functions-anthropic.py b/examples/thinking/thinking-functions-anthropic.py index b62a96452..f69b271fb 100644 --- a/examples/thinking/thinking-functions-anthropic.py +++ b/examples/thinking/thinking-functions-anthropic.py @@ -73,17 +73,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), + api_key=os.environ["ANTHROPIC_API_KEY"], settings=AnthropicLLMService.Settings( thinking=AnthropicLLMService.ThinkingConfig( type="enabled", diff --git a/examples/thinking/thinking-functions-google.py b/examples/thinking/thinking-functions-google.py index e06a0195b..680f2c70b 100644 --- a/examples/thinking/thinking-functions-google.py +++ b/examples/thinking/thinking-functions-google.py @@ -73,17 +73,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], # model="gemini-3-pro-preview", # A more powerful reasoning model, but slower settings=GoogleLLMService.Settings( thinking=GoogleLLMService.ThinkingConfig( diff --git a/examples/thinking/thinking-google.py b/examples/thinking/thinking-google.py index 94d3d28eb..12de4a313 100644 --- a/examples/thinking/thinking-google.py +++ b/examples/thinking/thinking-google.py @@ -52,17 +52,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], # model="gemini-3-pro-preview", # A more powerful reasoning model, but slower settings=GoogleLLMService.Settings( thinking=GoogleLLMService.ThinkingConfig( diff --git a/examples/transcription/transcription-assemblyai.py b/examples/transcription/transcription-assemblyai.py index f50f63380..f9db2c85e 100644 --- a/examples/transcription/transcription-assemblyai.py +++ b/examples/transcription/transcription-assemblyai.py @@ -48,7 +48,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = AssemblyAISTTService( - api_key=os.getenv("ASSEMBLYAI_API_KEY"), + api_key=os.environ["ASSEMBLYAI_API_KEY"], settings=AssemblyAISTTService.Settings( model="u3-rt-pro", ), diff --git a/examples/transcription/transcription-azure.py b/examples/transcription/transcription-azure.py index 301c6effd..1a551f745 100644 --- a/examples/transcription/transcription-azure.py +++ b/examples/transcription/transcription-azure.py @@ -54,7 +54,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = AzureSTTService( - api_key=os.getenv("AZURE_SPEECH_API_KEY"), + api_key=os.environ["AZURE_SPEECH_API_KEY"], region=os.getenv("AZURE_SPEECH_REGION"), ) diff --git a/examples/transcription/transcription-cartesia.py b/examples/transcription/transcription-cartesia.py index d3b83abb0..f86e5fa37 100644 --- a/examples/transcription/transcription-cartesia.py +++ b/examples/transcription/transcription-cartesia.py @@ -47,7 +47,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = CartesiaSTTService(api_key=os.getenv("CARTESIA_API_KEY")) + stt = CartesiaSTTService(api_key=os.environ["CARTESIA_API_KEY"]) tl = TranscriptionLogger() diff --git a/examples/transcription/transcription-deepgram.py b/examples/transcription/transcription-deepgram.py index 04246d237..92fe076e3 100644 --- a/examples/transcription/transcription-deepgram.py +++ b/examples/transcription/transcription-deepgram.py @@ -48,7 +48,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = DeepgramSTTService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], settings=DeepgramSTTService.Settings( language=Language.EN, ), diff --git a/examples/transcription/transcription-elevenlabs.py b/examples/transcription/transcription-elevenlabs.py index dbfd32ec6..548a12de2 100644 --- a/examples/transcription/transcription-elevenlabs.py +++ b/examples/transcription/transcription-elevenlabs.py @@ -49,7 +49,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = ElevenLabsRealtimeSTTService(api_key=os.getenv("ELEVENLABS_API_KEY")) + stt = ElevenLabsRealtimeSTTService(api_key=os.environ["ELEVENLABS_API_KEY"]) tl = TranscriptionLogger() vad_processor = VADProcessor(vad_analyzer=SileroVADAnalyzer()) diff --git a/examples/transcription/transcription-gladia-translation.py b/examples/transcription/transcription-gladia-translation.py index e6557cd15..477c73b23 100644 --- a/examples/transcription/transcription-gladia-translation.py +++ b/examples/transcription/transcription-gladia-translation.py @@ -55,9 +55,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") + region = os.getenv("GLADIA_REGION", "us-west") + assert region in ("us-west", "eu-west"), f"Invalid GLADIA_REGION: {region}" + stt = GladiaSTTService( - api_key=os.getenv("GLADIA_API_KEY"), - region=os.getenv("GLADIA_REGION"), + api_key=os.environ["GLADIA_API_KEY"], + region=region, settings=GladiaSTTService.Settings( language_config=LanguageConfig( languages=[Language.EN], diff --git a/examples/transcription/transcription-gladia.py b/examples/transcription/transcription-gladia.py index e98d4caf0..cd1152972 100644 --- a/examples/transcription/transcription-gladia.py +++ b/examples/transcription/transcription-gladia.py @@ -47,9 +47,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") + region = os.getenv("GLADIA_REGION", "us-west") + assert region in ("us-west", "eu-west"), f"Invalid GLADIA_REGION: {region}" + stt = GladiaSTTService( - api_key=os.getenv("GLADIA_API_KEY"), - region=os.getenv("GLADIA_REGION"), + api_key=os.environ["GLADIA_API_KEY"], + region=region, # settings=GladiaSTTSettings( # language_config=LanguageConfig( # languages=[Language.FR], diff --git a/examples/transcription/transcription-google-llm.py b/examples/transcription/transcription-google-llm.py index c22ed85a1..909711ecd 100644 --- a/examples/transcription/transcription-google-llm.py +++ b/examples/transcription/transcription-google-llm.py @@ -289,7 +289,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -301,7 +301,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): model="gemini-2.5-flash", system_instruction=conversation_system_message, ), - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["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 # our system message in the messages list. @@ -313,7 +313,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): model="gemini-2.5-flash", system_instruction=transcriber_system_message, ), - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], ) messages = [ diff --git a/examples/transcription/transcription-gradium.py b/examples/transcription/transcription-gradium.py index 59140466e..0b7a4412d 100644 --- a/examples/transcription/transcription-gradium.py +++ b/examples/transcription/transcription-gradium.py @@ -50,7 +50,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = GradiumSTTService( - api_key=os.getenv("GRADIUM_API_KEY"), + api_key=os.environ["GRADIUM_API_KEY"], api_endpoint_base_url="wss://us.api.gradium.ai/api/speech/asr", settings=GradiumSTTService.Settings( language=Language.EN, diff --git a/examples/transcription/transcription-mistral.py b/examples/transcription/transcription-mistral.py index b040b457c..fa471d2e6 100644 --- a/examples/transcription/transcription-mistral.py +++ b/examples/transcription/transcription-mistral.py @@ -54,7 +54,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = MistralSTTService( - api_key=os.getenv("MISTRAL_API_KEY"), + api_key=os.environ["MISTRAL_API_KEY"], ) tl = TranscriptionLogger() diff --git a/examples/transcription/transcription-openai.py b/examples/transcription/transcription-openai.py index cbbf0e13d..5f3072177 100644 --- a/examples/transcription/transcription-openai.py +++ b/examples/transcription/transcription-openai.py @@ -50,7 +50,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = OpenAIRealtimeSTTService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIRealtimeSTTService.Settings( model="gpt-4o-transcribe", prompt="Expect words related to dogs, such as breed names.", diff --git a/examples/transcription/transcription-soniox.py b/examples/transcription/transcription-soniox.py index 9476e9441..b912fa04c 100644 --- a/examples/transcription/transcription-soniox.py +++ b/examples/transcription/transcription-soniox.py @@ -54,7 +54,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = SonioxSTTService( - api_key=os.getenv("SONIOX_API_KEY"), + api_key=os.environ["SONIOX_API_KEY"], ) tl = TranscriptionLogger() diff --git a/examples/transcription/transcription-speechmatics.py b/examples/transcription/transcription-speechmatics.py index 2df30f67b..2134c8c97 100644 --- a/examples/transcription/transcription-speechmatics.py +++ b/examples/transcription/transcription-speechmatics.py @@ -64,7 +64,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = SpeechmaticsSTTService( - api_key=os.getenv("SPEECHMATICS_API_KEY"), + api_key=os.environ["SPEECHMATICS_API_KEY"], settings=SpeechmaticsSTTService.Settings( language=Language.EN, speaker_active_format="<{speaker_id}>{text}", diff --git a/examples/transports/transports-daily.py b/examples/transports/transports-daily.py index c6695e2f8..09deda2dd 100644 --- a/examples/transports/transports-daily.py +++ b/examples/transports/transports-daily.py @@ -49,14 +49,14 @@ async def main(): ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/transports/transports-livekit.py b/examples/transports/transports-livekit.py index b2ec6b49c..8bb147c04 100644 --- a/examples/transports/transports-livekit.py +++ b/examples/transports/transports-livekit.py @@ -53,17 +53,17 @@ async def main(): ), ) - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/transports/transports-small-webrtc.py b/examples/transports/transports-small-webrtc.py index 18403940b..2cb6d4bb0 100644 --- a/examples/transports/transports-small-webrtc.py +++ b/examples/transports/transports-small-webrtc.py @@ -62,17 +62,17 @@ async def run_example(webrtc_connection: SmallWebRTCConnection): ), ) - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/turn-management/turn-management-detect-user-idle.py b/examples/turn-management/turn-management-detect-user-idle.py index a159f0c4e..8391e3908 100644 --- a/examples/turn-management/turn-management-detect-user-idle.py +++ b/examples/turn-management/turn-management-detect-user-idle.py @@ -11,6 +11,7 @@ import os from dotenv import load_dotenv from loguru import logger +from pipecat.adapters.base_llm_adapter import LLMContextMessage from pipecat.adapters.schemas.function_schema import FunctionSchema from pipecat.adapters.schemas.tools_schema import ToolsSchema from pipecat.audio.vad.silero import SileroVADAnalyzer @@ -59,7 +60,7 @@ class IdleHandler: if self._retry_count == 1: # First attempt: Add a gentle prompt to the conversation - message = { + message: LLMContextMessage = { "role": "developer", "content": "The user has been quiet. Politely and briefly ask if they're still there.", } @@ -111,17 +112,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/turn-management/turn-management-filter-incomplete-turns.py b/examples/turn-management/turn-management-filter-incomplete-turns.py index fca89f66c..81273aaaa 100644 --- a/examples/turn-management/turn-management-filter-incomplete-turns.py +++ b/examples/turn-management/turn-management-filter-incomplete-turns.py @@ -66,17 +66,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/turn-management/turn-management-interruption-config.py b/examples/turn-management/turn-management-interruption-config.py index d625910df..ee19075df 100644 --- a/examples/turn-management/turn-management-interruption-config.py +++ b/examples/turn-management/turn-management-interruption-config.py @@ -55,17 +55,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/turn-management/turn-management-smart-turn-local-coreml.py b/examples/turn-management/turn-management-smart-turn-local-coreml.py index 3042ceb5a..68e831bba 100644 --- a/examples/turn-management/turn-management-smart-turn-local-coreml.py +++ b/examples/turn-management/turn-management-smart-turn-local-coreml.py @@ -49,7 +49,7 @@ load_dotenv(override=True) # Then set the env variable: # export LOCAL_SMART_TURN_MODEL_PATH=./smart-turn # or add it to your .env file -smart_turn_model_path = os.getenv("LOCAL_SMART_TURN_MODEL_PATH") +smart_turn_model_path = os.environ["LOCAL_SMART_TURN_MODEL_PATH"] # We use lambdas to defer transport parameter creation until the transport # type is selected at runtime. @@ -72,17 +72,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/turn-management/turn-management-smart-turn-local.py b/examples/turn-management/turn-management-smart-turn-local.py index 7a73a4324..5509f0264 100644 --- a/examples/turn-management/turn-management-smart-turn-local.py +++ b/examples/turn-management/turn-management-smart-turn-local.py @@ -54,17 +54,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/turn-management/turn-management-turn-tracking-observer.py b/examples/turn-management/turn-management-turn-tracking-observer.py index 14d63d40b..86f061906 100644 --- a/examples/turn-management/turn-management-turn-tracking-observer.py +++ b/examples/turn-management/turn-management-turn-tracking-observer.py @@ -69,17 +69,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/turn-management/turn-management-user-assistant-turns.py b/examples/turn-management/turn-management-user-assistant-turns.py index 380c4866d..879eb1cdc 100644 --- a/examples/turn-management/turn-management-user-assistant-turns.py +++ b/examples/turn-management/turn-management-user-assistant-turns.py @@ -118,17 +118,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/turn-management/turn-management-user-mute-strategy.py b/examples/turn-management/turn-management-user-mute-strategy.py index 6e826f81d..0f9b24a8c 100644 --- a/examples/turn-management/turn-management-user-mute-strategy.py +++ b/examples/turn-management/turn-management-user-mute-strategy.py @@ -69,17 +69,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = DeepgramTTSService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], settings=DeepgramTTSService.Settings( voice="aura-2-helena-en", ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant who can check the weather. Always check the weather when a location is mentioned. Respond concisely and naturally. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points.", ), diff --git a/examples/update-settings/llm/llm-anthropic.py b/examples/update-settings/llm/llm-anthropic.py index 67ba6e9e9..885981ddd 100644 --- a/examples/update-settings/llm/llm-anthropic.py +++ b/examples/update-settings/llm/llm-anthropic.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), + api_key=os.environ["ANTHROPIC_API_KEY"], settings=AnthropicLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-aws-bedrock.py b/examples/update-settings/llm/llm-aws-bedrock.py index 168bb6bf0..6facff628 100644 --- a/examples/update-settings/llm/llm-aws-bedrock.py +++ b/examples/update-settings/llm/llm-aws-bedrock.py @@ -50,10 +50,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/update-settings/llm/llm-aws-nova-sonic.py b/examples/update-settings/llm/llm-aws-nova-sonic.py index 99fa5cd7f..19ca3c805 100644 --- a/examples/update-settings/llm/llm-aws-nova-sonic.py +++ b/examples/update-settings/llm/llm-aws-nova-sonic.py @@ -49,9 +49,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") llm = AWSNovaSonicLLMService( - secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"), - access_key_id=os.getenv("AWS_ACCESS_KEY_ID"), - region=os.getenv("AWS_REGION"), + secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"], + access_key_id=os.environ["AWS_ACCESS_KEY_ID"], + region=os.environ["AWS_REGION"], settings=AWSNovaSonicLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-azure-realtime.py b/examples/update-settings/llm/llm-azure-realtime.py index fde633912..3d724bd53 100644 --- a/examples/update-settings/llm/llm-azure-realtime.py +++ b/examples/update-settings/llm/llm-azure-realtime.py @@ -10,6 +10,7 @@ import os from dotenv import load_dotenv from loguru import logger +from pipecat.adapters.base_llm_adapter import LLMContextMessage from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.frames.frames import LLMRunFrame, LLMUpdateSettingsFrame from pipecat.pipeline.pipeline import Pipeline @@ -51,11 +52,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") llm = AzureRealtimeLLMService( - api_key=os.getenv("AZURE_REALTIME_API_KEY"), - base_url=os.getenv("AZURE_REALTIME_BASE_URL"), + api_key=os.environ["AZURE_REALTIME_API_KEY"], + base_url=os.environ["AZURE_REALTIME_BASE_URL"], ) - messages = [ + messages: list[LLMContextMessage] = [ { "role": "system", "content": "You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/update-settings/llm/llm-azure.py b/examples/update-settings/llm/llm-azure.py index 60d151484..3f9f5da57 100644 --- a/examples/update-settings/llm/llm-azure.py +++ b/examples/update-settings/llm/llm-azure.py @@ -50,18 +50,18 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( 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"), + api_key=os.environ["AZURE_CHATGPT_API_KEY"], + endpoint=os.environ["AZURE_CHATGPT_ENDPOINT"], settings=AzureLLMService.Settings( model=os.getenv("AZURE_CHATGPT_MODEL"), system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/update-settings/llm/llm-cerebras.py b/examples/update-settings/llm/llm-cerebras.py index edda71d49..232723a3e 100644 --- a/examples/update-settings/llm/llm-cerebras.py +++ b/examples/update-settings/llm/llm-cerebras.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = CerebrasLLMService( - api_key=os.getenv("CEREBRAS_API_KEY"), + api_key=os.environ["CEREBRAS_API_KEY"], settings=CerebrasLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-deepseek.py b/examples/update-settings/llm/llm-deepseek.py index adcb63259..a7df0469b 100644 --- a/examples/update-settings/llm/llm-deepseek.py +++ b/examples/update-settings/llm/llm-deepseek.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = DeepSeekLLMService( - api_key=os.getenv("DEEPSEEK_API_KEY"), + api_key=os.environ["DEEPSEEK_API_KEY"], settings=DeepSeekLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-fireworks.py b/examples/update-settings/llm/llm-fireworks.py index 3468d8dec..154bb63ce 100644 --- a/examples/update-settings/llm/llm-fireworks.py +++ b/examples/update-settings/llm/llm-fireworks.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = FireworksLLMService( - api_key=os.getenv("FIREWORKS_API_KEY"), + api_key=os.environ["FIREWORKS_API_KEY"], settings=FireworksLLMService.Settings( model="accounts/fireworks/models/gpt-oss-20b", system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/update-settings/llm/llm-gemini-live-vertex.py b/examples/update-settings/llm/llm-gemini-live-vertex.py index c18fb34c5..3992be309 100644 --- a/examples/update-settings/llm/llm-gemini-live-vertex.py +++ b/examples/update-settings/llm/llm-gemini-live-vertex.py @@ -49,9 +49,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") llm = GeminiLiveVertexLLMService( - credentials=os.getenv("GOOGLE_VERTEX_TEST_CREDENTIALS"), - project_id=os.getenv("GOOGLE_CLOUD_PROJECT_ID"), - location=os.getenv("GOOGLE_CLOUD_LOCATION"), + credentials=os.environ["GOOGLE_VERTEX_TEST_CREDENTIALS"], + project_id=os.environ["GOOGLE_CLOUD_PROJECT_ID"], + location=os.environ["GOOGLE_CLOUD_LOCATION"], settings=GeminiLiveVertexLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-gemini-live.py b/examples/update-settings/llm/llm-gemini-live.py index dafc9efe4..0c066648e 100644 --- a/examples/update-settings/llm/llm-gemini-live.py +++ b/examples/update-settings/llm/llm-gemini-live.py @@ -49,7 +49,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") llm = GeminiLiveLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GeminiLiveLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-google-vertex.py b/examples/update-settings/llm/llm-google-vertex.py index b63b176bc..7c4ca8446 100644 --- a/examples/update-settings/llm/llm-google-vertex.py +++ b/examples/update-settings/llm/llm-google-vertex.py @@ -50,10 +50,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -61,8 +61,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = GoogleVertexLLMService( credentials=os.getenv("GOOGLE_VERTEX_TEST_CREDENTIALS"), - project_id=os.getenv("GOOGLE_CLOUD_PROJECT_ID"), - location=os.getenv("GOOGLE_CLOUD_LOCATION"), + project_id=os.environ["GOOGLE_CLOUD_PROJECT_ID"], + location=os.environ["GOOGLE_CLOUD_LOCATION"], settings=GoogleVertexLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-google.py b/examples/update-settings/llm/llm-google.py index 09a9d686d..69b474190 100644 --- a/examples/update-settings/llm/llm-google.py +++ b/examples/update-settings/llm/llm-google.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-grok-realtime.py b/examples/update-settings/llm/llm-grok-realtime.py index 304ccce8e..4ab28cdda 100644 --- a/examples/update-settings/llm/llm-grok-realtime.py +++ b/examples/update-settings/llm/llm-grok-realtime.py @@ -10,6 +10,7 @@ import os from dotenv import load_dotenv from loguru import logger +from pipecat.adapters.base_llm_adapter import LLMContextMessage from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.frames.frames import LLMRunFrame, LLMUpdateSettingsFrame from pipecat.pipeline.pipeline import Pipeline @@ -50,9 +51,9 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - llm = GrokRealtimeLLMService(api_key=os.getenv("XAI_API_KEY")) + llm = GrokRealtimeLLMService(api_key=os.environ["XAI_API_KEY"]) - messages = [ + messages: list[LLMContextMessage] = [ { "role": "system", "content": "You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/update-settings/llm/llm-grok.py b/examples/update-settings/llm/llm-grok.py index dedb7b950..463b27807 100644 --- a/examples/update-settings/llm/llm-grok.py +++ b/examples/update-settings/llm/llm-grok.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = GrokLLMService( - api_key=os.getenv("XAI_API_KEY"), + api_key=os.environ["XAI_API_KEY"], settings=GrokLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-groq.py b/examples/update-settings/llm/llm-groq.py index 771a5cbe9..365d8b4d4 100644 --- a/examples/update-settings/llm/llm-groq.py +++ b/examples/update-settings/llm/llm-groq.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = GroqLLMService( - api_key=os.getenv("GROQ_API_KEY"), + api_key=os.environ["GROQ_API_KEY"], settings=GroqLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-mistral.py b/examples/update-settings/llm/llm-mistral.py index 5da4d47b7..4aa66197e 100644 --- a/examples/update-settings/llm/llm-mistral.py +++ b/examples/update-settings/llm/llm-mistral.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = MistralLLMService( - api_key=os.getenv("MISTRAL_API_KEY"), + api_key=os.environ["MISTRAL_API_KEY"], settings=MistralLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-nvidia.py b/examples/update-settings/llm/llm-nvidia.py index 06c45dd5d..a44083821 100644 --- a/examples/update-settings/llm/llm-nvidia.py +++ b/examples/update-settings/llm/llm-nvidia.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = NvidiaLLMService( - api_key=os.getenv("NVIDIA_API_KEY"), + api_key=os.environ["NVIDIA_API_KEY"], settings=NvidiaLLMService.Settings( model="meta/llama-3.1-405b-instruct", system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/update-settings/llm/llm-ollama.py b/examples/update-settings/llm/llm-ollama.py index 90ddcbfb0..ac9892bee 100644 --- a/examples/update-settings/llm/llm-ollama.py +++ b/examples/update-settings/llm/llm-ollama.py @@ -50,10 +50,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/update-settings/llm/llm-openai-realtime.py b/examples/update-settings/llm/llm-openai-realtime.py index 83cdb9fa7..120d8a86e 100644 --- a/examples/update-settings/llm/llm-openai-realtime.py +++ b/examples/update-settings/llm/llm-openai-realtime.py @@ -10,6 +10,7 @@ import os from dotenv import load_dotenv from loguru import logger +from pipecat.adapters.base_llm_adapter import LLMContextMessage from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.frames.frames import LLMRunFrame, LLMUpdateSettingsFrame from pipecat.pipeline.pipeline import Pipeline @@ -50,9 +51,9 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - llm = OpenAIRealtimeLLMService(api_key=os.getenv("OPENAI_API_KEY")) + llm = OpenAIRealtimeLLMService(api_key=os.environ["OPENAI_API_KEY"]) - messages = [ + messages: list[LLMContextMessage] = [ { "role": "system", "content": "You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/update-settings/llm/llm-openai-responses-http.py b/examples/update-settings/llm/llm-openai-responses-http.py index 051a2f71e..0e7d6ec44 100644 --- a/examples/update-settings/llm/llm-openai-responses-http.py +++ b/examples/update-settings/llm/llm-openai-responses-http.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesHttpLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIResponsesHttpLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-openai-responses.py b/examples/update-settings/llm/llm-openai-responses.py index 8c214b639..d4857bab1 100644 --- a/examples/update-settings/llm/llm-openai-responses.py +++ b/examples/update-settings/llm/llm-openai-responses.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIResponsesLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-openai.py b/examples/update-settings/llm/llm-openai.py index 15ee4554a..dee6ba8cf 100644 --- a/examples/update-settings/llm/llm-openai.py +++ b/examples/update-settings/llm/llm-openai.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-openrouter.py b/examples/update-settings/llm/llm-openrouter.py index 7b8aef6d8..3c554b921 100644 --- a/examples/update-settings/llm/llm-openrouter.py +++ b/examples/update-settings/llm/llm-openrouter.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenRouterLLMService( - api_key=os.getenv("OPENROUTER_API_KEY"), + api_key=os.environ["OPENROUTER_API_KEY"], settings=OpenRouterLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-perplexity.py b/examples/update-settings/llm/llm-perplexity.py index 99a40c614..d1e2aae4a 100644 --- a/examples/update-settings/llm/llm-perplexity.py +++ b/examples/update-settings/llm/llm-perplexity.py @@ -50,25 +50,18 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) - llm = PerplexityLLMService(api_key=os.getenv("PERPLEXITY_API_KEY")) + llm = PerplexityLLMService(api_key=os.environ["PERPLEXITY_API_KEY"]) - messages = [ - { - "role": "developer", - "content": "You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. Start by introducing yourself.", - }, - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), @@ -98,6 +91,9 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): @transport.event_handler("on_client_connected") async def on_client_connected(transport, client): logger.info(f"Client connected") + context.add_message( + {"role": "developer", "content": "Please introduce yourself to the user."} + ) await task.queue_frames([LLMRunFrame()]) await asyncio.sleep(10) diff --git a/examples/update-settings/llm/llm-qwen.py b/examples/update-settings/llm/llm-qwen.py index ff7d126d3..585a7c2da 100644 --- a/examples/update-settings/llm/llm-qwen.py +++ b/examples/update-settings/llm/llm-qwen.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = QwenLLMService( - api_key=os.getenv("QWEN_API_KEY"), + api_key=os.environ["QWEN_API_KEY"], settings=QwenLLMService.Settings( model="qwen2.5-72b-instruct", system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/update-settings/llm/llm-sambanova.py b/examples/update-settings/llm/llm-sambanova.py index 4f03db5f2..c543fcee2 100644 --- a/examples/update-settings/llm/llm-sambanova.py +++ b/examples/update-settings/llm/llm-sambanova.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = SambaNovaLLMService( - api_key=os.getenv("SAMBANOVA_API_KEY"), + api_key=os.environ["SAMBANOVA_API_KEY"], settings=SambaNovaLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-sarvam.py b/examples/update-settings/llm/llm-sarvam.py index 62102238f..2966f46b8 100644 --- a/examples/update-settings/llm/llm-sarvam.py +++ b/examples/update-settings/llm/llm-sarvam.py @@ -47,31 +47,26 @@ transport_params = { } -def _require_env(name: str) -> str: - value = os.getenv(name) - if not value: - raise ValueError(f"Environment variable `{name}` is required.") - return value - - async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info("Starting bot") stt = SarvamSTTService( settings=SarvamSTTService.Settings(model="saaras:v3"), - api_key=_require_env("SARVAM_API_KEY"), + api_key=os.environ["SARVAM_API_KEY"], ) tts = SarvamTTSService( settings=SarvamTTSService.Settings(model="bulbul:v3"), - api_key=_require_env("SARVAM_API_KEY"), + api_key=os.environ["SARVAM_API_KEY"], ) llm = SarvamLLMService( - api_key=_require_env("SARVAM_API_KEY"), - settings=SarvamLLMService.Settings(model="sarvam-30b"), - 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." + api_key=os.environ["SARVAM_API_KEY"], + settings=SarvamLLMService.Settings( + model="sarvam-30b", + 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/update-settings/llm/llm-together.py b/examples/update-settings/llm/llm-together.py index 3144f1906..2e1a8cb7a 100644 --- a/examples/update-settings/llm/llm-together.py +++ b/examples/update-settings/llm/llm-together.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = TogetherLLMService( - api_key=os.getenv("TOGETHER_API_KEY"), + api_key=os.environ["TOGETHER_API_KEY"], settings=TogetherLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/llm/llm-ultravox-realtime.py b/examples/update-settings/llm/llm-ultravox-realtime.py index f77aa4252..4c530735e 100644 --- a/examples/update-settings/llm/llm-ultravox-realtime.py +++ b/examples/update-settings/llm/llm-ultravox-realtime.py @@ -11,6 +11,7 @@ import os from dotenv import load_dotenv from loguru import logger +from pipecat.adapters.base_llm_adapter import LLMContextMessage from pipecat.adapters.schemas.tools_schema import ToolsSchema from pipecat.audio.vad.silero import SileroVADAnalyzer from pipecat.frames.frames import LLMRunFrame, LLMUpdateSettingsFrame @@ -55,7 +56,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): llm = UltravoxRealtimeLLMService( params=OneShotInputParams( - api_key=os.getenv("ULTRAVOX_API_KEY"), + api_key=os.environ["ULTRAVOX_API_KEY"], system_prompt=system_prompt, temperature=0.3, max_duration=datetime.timedelta(minutes=3), @@ -63,7 +64,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): one_shot_selected_tools=ToolsSchema(standard_tools=[]), ) - messages = [ + messages: list[LLMContextMessage] = [ { "role": "system", "content": system_prompt, diff --git a/examples/update-settings/stt/stt-assemblyai.py b/examples/update-settings/stt/stt-assemblyai.py index 8017b6021..276499bb1 100644 --- a/examples/update-settings/stt/stt-assemblyai.py +++ b/examples/update-settings/stt/stt-assemblyai.py @@ -51,21 +51,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = AssemblyAISTTService( - api_key=os.getenv("ASSEMBLYAI_API_KEY"), + api_key=os.environ["ASSEMBLYAI_API_KEY"], settings=AssemblyAISTTService.Settings( model="u3-rt-pro", ), ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Try saying difficult names like 'Xiomara', 'Saoirse', or 'Krzystof' to test transcription accuracy.", ), diff --git a/examples/update-settings/stt/stt-aws-transcribe.py b/examples/update-settings/stt/stt-aws-transcribe.py index 25c2f272a..503ecae39 100644 --- a/examples/update-settings/stt/stt-aws-transcribe.py +++ b/examples/update-settings/stt/stt-aws-transcribe.py @@ -54,14 +54,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = AWSTranscribeSTTService() tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-azure.py b/examples/update-settings/stt/stt-azure.py index adc242d3c..e1f8b62ad 100644 --- a/examples/update-settings/stt/stt-azure.py +++ b/examples/update-settings/stt/stt-azure.py @@ -52,19 +52,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = AzureSTTService( - api_key=os.getenv("AZURE_SPEECH_API_KEY"), + api_key=os.environ["AZURE_SPEECH_API_KEY"], region=os.getenv("AZURE_SPEECH_REGION"), ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-cartesia.py b/examples/update-settings/stt/stt-cartesia.py index 79daec9fd..2f5602b8d 100644 --- a/examples/update-settings/stt/stt-cartesia.py +++ b/examples/update-settings/stt/stt-cartesia.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = CartesiaSTTService(api_key=os.getenv("CARTESIA_API_KEY")) + stt = CartesiaSTTService(api_key=os.environ["CARTESIA_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-deepgram-flux.py b/examples/update-settings/stt/stt-deepgram-flux.py index 5db99a327..f8810e2fd 100644 --- a/examples/update-settings/stt/stt-deepgram-flux.py +++ b/examples/update-settings/stt/stt-deepgram-flux.py @@ -56,7 +56,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # across English and Spanish. TranscriptionFrame.language will reflect # whichever language Flux detected for each turn. stt = DeepgramFluxSTTService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], settings=DeepgramFluxSTTService.Settings( model="flux-general-multi", language_hints=[Language.EN, Language.ES], @@ -64,14 +64,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-deepgram-sagemaker.py b/examples/update-settings/stt/stt-deepgram-sagemaker.py index aa61eaa1e..05a655abc 100644 --- a/examples/update-settings/stt/stt-deepgram-sagemaker.py +++ b/examples/update-settings/stt/stt-deepgram-sagemaker.py @@ -52,19 +52,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = DeepgramSageMakerSTTService( - endpoint_name=os.getenv("SAGEMAKER_STT_ENDPOINT_NAME"), - region=os.getenv("AWS_REGION"), + endpoint_name=os.environ["SAGEMAKER_STT_ENDPOINT_NAME"], + region=os.environ["AWS_REGION"], ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-deepgram.py b/examples/update-settings/stt/stt-deepgram.py index a083244d0..9f345b1c3 100644 --- a/examples/update-settings/stt/stt-deepgram.py +++ b/examples/update-settings/stt/stt-deepgram.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-elevenlabs-realtime.py b/examples/update-settings/stt/stt-elevenlabs-realtime.py index f2cba36ec..8a195ad48 100644 --- a/examples/update-settings/stt/stt-elevenlabs-realtime.py +++ b/examples/update-settings/stt/stt-elevenlabs-realtime.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = ElevenLabsRealtimeSTTService(api_key=os.getenv("ELEVENLABS_API_KEY")) + stt = ElevenLabsRealtimeSTTService(api_key=os.environ["ELEVENLABS_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-elevenlabs.py b/examples/update-settings/stt/stt-elevenlabs.py index 03efdc71e..3b3623264 100644 --- a/examples/update-settings/stt/stt-elevenlabs.py +++ b/examples/update-settings/stt/stt-elevenlabs.py @@ -54,19 +54,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): async with aiohttp.ClientSession() as session: stt = ElevenLabsSTTService( - api_key=os.getenv("ELEVENLABS_API_KEY"), + api_key=os.environ["ELEVENLABS_API_KEY"], aiohttp_session=session, ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-fal.py b/examples/update-settings/stt/stt-fal.py index 83b7dbc79..5dccd4d36 100644 --- a/examples/update-settings/stt/stt-fal.py +++ b/examples/update-settings/stt/stt-fal.py @@ -53,14 +53,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): stt = FalSTTService(api_key=os.getenv("FAL_KEY")) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-gladia.py b/examples/update-settings/stt/stt-gladia.py index 972456853..4449eff06 100644 --- a/examples/update-settings/stt/stt-gladia.py +++ b/examples/update-settings/stt/stt-gladia.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = GladiaSTTService(api_key=os.getenv("GLADIA_API_KEY")) + stt = GladiaSTTService(api_key=os.environ["GLADIA_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-google.py b/examples/update-settings/stt/stt-google.py index 58b0ff357..76ea1325d 100644 --- a/examples/update-settings/stt/stt-google.py +++ b/examples/update-settings/stt/stt-google.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = GoogleSTTService(credentials=os.getenv("GOOGLE_TEST_CREDENTIALS")) + stt = GoogleSTTService(credentials=os.environ["GOOGLE_TEST_CREDENTIALS"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-gradium.py b/examples/update-settings/stt/stt-gradium.py index aebced030..876b20260 100644 --- a/examples/update-settings/stt/stt-gradium.py +++ b/examples/update-settings/stt/stt-gradium.py @@ -51,19 +51,19 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = GradiumSTTService( - api_key=os.getenv("GRADIUM_API_KEY"), + api_key=os.environ["GRADIUM_API_KEY"], api_endpoint_base_url="wss://us.api.gradium.ai/api/speech/asr", ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-groq.py b/examples/update-settings/stt/stt-groq.py index f612ba05b..033ed4c03 100644 --- a/examples/update-settings/stt/stt-groq.py +++ b/examples/update-settings/stt/stt-groq.py @@ -51,18 +51,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = GroqSTTService( - api_key=os.getenv("GROQ_API_KEY"), + api_key=os.environ["GROQ_API_KEY"], ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-nvidia-segmented.py b/examples/update-settings/stt/stt-nvidia-segmented.py index d2880d446..1cce6fba2 100644 --- a/examples/update-settings/stt/stt-nvidia-segmented.py +++ b/examples/update-settings/stt/stt-nvidia-segmented.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = NvidiaSegmentedSTTService(api_key=os.getenv("NVIDIA_API_KEY")) + stt = NvidiaSegmentedSTTService(api_key=os.environ["NVIDIA_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-nvidia.py b/examples/update-settings/stt/stt-nvidia.py index e339218e8..499269f86 100644 --- a/examples/update-settings/stt/stt-nvidia.py +++ b/examples/update-settings/stt/stt-nvidia.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = NvidiaSTTService(api_key=os.getenv("NVIDIA_API_KEY")) + stt = NvidiaSTTService(api_key=os.environ["NVIDIA_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-openai-realtime.py b/examples/update-settings/stt/stt-openai-realtime.py index e5366eb7f..33c4c4e7d 100644 --- a/examples/update-settings/stt/stt-openai-realtime.py +++ b/examples/update-settings/stt/stt-openai-realtime.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = OpenAIRealtimeSTTService(api_key=os.getenv("OPENAI_API_KEY")) + stt = OpenAIRealtimeSTTService(api_key=os.environ["OPENAI_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-sarvam.py b/examples/update-settings/stt/stt-sarvam.py index ddb76275d..60da61359 100644 --- a/examples/update-settings/stt/stt-sarvam.py +++ b/examples/update-settings/stt/stt-sarvam.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = SarvamSTTService(api_key=os.getenv("SARVAM_API_KEY")) + stt = SarvamSTTService(api_key=os.environ["SARVAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-soniox.py b/examples/update-settings/stt/stt-soniox.py index 05b3c267f..adf3fb547 100644 --- a/examples/update-settings/stt/stt-soniox.py +++ b/examples/update-settings/stt/stt-soniox.py @@ -51,17 +51,17 @@ 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")) + stt = SonioxSTTService(api_key=os.environ["SONIOX_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-speechmatics.py b/examples/update-settings/stt/stt-speechmatics.py index 93c97c827..f92d2ff7e 100644 --- a/examples/update-settings/stt/stt-speechmatics.py +++ b/examples/update-settings/stt/stt-speechmatics.py @@ -52,7 +52,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = SpeechmaticsSTTService( - api_key=os.getenv("SPEECHMATICS_API_KEY"), + api_key=os.environ["SPEECHMATICS_API_KEY"], settings=SpeechmaticsSTTService.Settings( enable_diarization=True, speaker_active_format="<{speaker_id}>{text}", @@ -61,14 +61,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-whisper-api.py b/examples/update-settings/stt/stt-whisper-api.py index 84dea00a2..372e6a36e 100644 --- a/examples/update-settings/stt/stt-whisper-api.py +++ b/examples/update-settings/stt/stt-whisper-api.py @@ -56,18 +56,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # - SambaNova # - Groq stt = OpenAISTTService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-whisper-mlx.py b/examples/update-settings/stt/stt-whisper-mlx.py index a13c053cf..7e9e5e4e1 100644 --- a/examples/update-settings/stt/stt-whisper-mlx.py +++ b/examples/update-settings/stt/stt-whisper-mlx.py @@ -57,14 +57,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/stt/stt-whisper.py b/examples/update-settings/stt/stt-whisper.py index d09c4f3b4..e25f3915b 100644 --- a/examples/update-settings/stt/stt-whisper.py +++ b/examples/update-settings/stt/stt-whisper.py @@ -57,14 +57,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-asyncai-http.py b/examples/update-settings/tts/tts-asyncai-http.py index 93ca099b0..5f6342114 100644 --- a/examples/update-settings/tts/tts-asyncai-http.py +++ b/examples/update-settings/tts/tts-asyncai-http.py @@ -55,7 +55,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = AsyncAIHttpTTSService( api_key=os.getenv("ASYNCAI_API_KEY", ""), @@ -66,7 +66,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-asyncai.py b/examples/update-settings/tts/tts-asyncai.py index a24e37c9e..3d7701288 100644 --- a/examples/update-settings/tts/tts-asyncai.py +++ b/examples/update-settings/tts/tts-asyncai.py @@ -51,7 +51,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = AsyncAITTSService( api_key=os.getenv("ASYNCAI_API_KEY", ""), @@ -61,7 +61,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-aws-polly.py b/examples/update-settings/tts/tts-aws-polly.py index b00c6982b..6ddeaf04b 100644 --- a/examples/update-settings/tts/tts-aws-polly.py +++ b/examples/update-settings/tts/tts-aws-polly.py @@ -50,12 +50,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = AWSPollyTTSService() llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-azure-http.py b/examples/update-settings/tts/tts-azure-http.py index a0193b063..5b3d6adb3 100644 --- a/examples/update-settings/tts/tts-azure-http.py +++ b/examples/update-settings/tts/tts-azure-http.py @@ -50,15 +50,15 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = AzureHttpTTSService( - api_key=os.getenv("AZURE_SPEECH_API_KEY"), - region=os.getenv("AZURE_SPEECH_REGION"), + api_key=os.environ["AZURE_SPEECH_API_KEY"], + region=os.environ["AZURE_SPEECH_REGION"], ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-azure.py b/examples/update-settings/tts/tts-azure.py index 46daa6781..a3a1eb822 100644 --- a/examples/update-settings/tts/tts-azure.py +++ b/examples/update-settings/tts/tts-azure.py @@ -50,15 +50,15 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = AzureTTSService( - api_key=os.getenv("AZURE_SPEECH_API_KEY"), - region=os.getenv("AZURE_SPEECH_REGION"), + api_key=os.environ["AZURE_SPEECH_API_KEY"], + region=os.environ["AZURE_SPEECH_REGION"], ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-camb.py b/examples/update-settings/tts/tts-camb.py index 97166ad0f..874489d97 100644 --- a/examples/update-settings/tts/tts-camb.py +++ b/examples/update-settings/tts/tts-camb.py @@ -51,12 +51,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) - tts = CambTTSService(api_key=os.getenv("CAMB_API_KEY")) + tts = CambTTSService(api_key=os.environ["CAMB_API_KEY"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-cartesia-http.py b/examples/update-settings/tts/tts-cartesia-http.py index 84d3188af..b126d1dee 100644 --- a/examples/update-settings/tts/tts-cartesia-http.py +++ b/examples/update-settings/tts/tts-cartesia-http.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaHttpTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaHttpTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-cartesia.py b/examples/update-settings/tts/tts-cartesia.py index 71d804875..7f267a4d7 100644 --- a/examples/update-settings/tts/tts-cartesia.py +++ b/examples/update-settings/tts/tts-cartesia.py @@ -52,17 +52,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-deepgram-http.py b/examples/update-settings/tts/tts-deepgram-http.py index 16083e95e..0aa24c4e5 100644 --- a/examples/update-settings/tts/tts-deepgram-http.py +++ b/examples/update-settings/tts/tts-deepgram-http.py @@ -54,15 +54,15 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = DeepgramHttpTTSService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], aiohttp_session=session, ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-deepgram-sagemaker.py b/examples/update-settings/tts/tts-deepgram-sagemaker.py index 1dfd2a365..47329b1f3 100644 --- a/examples/update-settings/tts/tts-deepgram-sagemaker.py +++ b/examples/update-settings/tts/tts-deepgram-sagemaker.py @@ -50,16 +50,16 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = DeepgramSageMakerTTSService( - endpoint_name=os.getenv("SAGEMAKER_TTS_ENDPOINT_NAME"), - region=os.getenv("AWS_REGION"), + endpoint_name=os.environ["SAGEMAKER_TTS_ENDPOINT_NAME"], + region=os.environ["AWS_REGION"], voice="aura-2-helena-en", ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-deepgram.py b/examples/update-settings/tts/tts-deepgram.py index 596d12dfa..8e532937a 100644 --- a/examples/update-settings/tts/tts-deepgram.py +++ b/examples/update-settings/tts/tts-deepgram.py @@ -50,12 +50,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) - tts = DeepgramTTSService(api_key=os.getenv("DEEPGRAM_API_KEY")) + tts = DeepgramTTSService(api_key=os.environ["DEEPGRAM_API_KEY"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-elevenlabs-http.py b/examples/update-settings/tts/tts-elevenlabs-http.py index 60dab3017..ac85a1452 100644 --- a/examples/update-settings/tts/tts-elevenlabs-http.py +++ b/examples/update-settings/tts/tts-elevenlabs-http.py @@ -54,16 +54,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = ElevenLabsHttpTTSService( - api_key=os.getenv("ELEVENLABS_API_KEY"), - settings=ElevenLabsHttpTTSService.Settings(voice=os.getenv("ELEVENLABS_VOICE_ID")), + api_key=os.environ["ELEVENLABS_API_KEY"], + settings=ElevenLabsHttpTTSService.Settings( + voice=os.getenv( + "ELEVENLABS_VOICE_ID", + "Xb7hH8MSUJpSbSDYk0k2", + ) + ), aiohttp_session=session, ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-elevenlabs.py b/examples/update-settings/tts/tts-elevenlabs.py index 83de8165f..9aeadf993 100644 --- a/examples/update-settings/tts/tts-elevenlabs.py +++ b/examples/update-settings/tts/tts-elevenlabs.py @@ -50,15 +50,20 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = ElevenLabsTTSService( - api_key=os.getenv("ELEVENLABS_API_KEY"), - settings=ElevenLabsTTSService.Settings(voice=os.getenv("ELEVENLABS_VOICE_ID")), + api_key=os.environ["ELEVENLABS_API_KEY"], + settings=ElevenLabsTTSService.Settings( + voice=os.getenv( + "ELEVENLABS_VOICE_ID", + "Xb7hH8MSUJpSbSDYk0k2", + ) + ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), @@ -109,7 +114,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info("Updating ElevenLabs TTS settings: switching to a different voice") await task.queue_frame( TTSUpdateSettingsFrame( - delta=ElevenLabsTTSService.Settings(voice=os.getenv("ELEVENLABS_VOICE_ID_ALT")) + delta=ElevenLabsTTSService.Settings( + voice=os.getenv( + "ELEVENLABS_VOICE_ID_ALT", + "CwhRBWXzGAHq8TQ4Fs17", + ) + ) ) ) diff --git a/examples/update-settings/tts/tts-fish.py b/examples/update-settings/tts/tts-fish.py index f486ad9d1..44566d915 100644 --- a/examples/update-settings/tts/tts-fish.py +++ b/examples/update-settings/tts/tts-fish.py @@ -50,17 +50,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = FishAudioTTSService( - api_key=os.getenv("FISH_API_KEY"), + api_key=os.environ["FISH_API_KEY"], settings=FishAudioTTSService.Settings( voice="4ce7e917cedd4bc2bb2e6ff3a46acaa1" ), # Barack Obama ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-gemini.py b/examples/update-settings/tts/tts-gemini.py index e984c3575..a6b56ac54 100644 --- a/examples/update-settings/tts/tts-gemini.py +++ b/examples/update-settings/tts/tts-gemini.py @@ -51,10 +51,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = GeminiTTSService( - credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + credentials=os.environ["GOOGLE_TEST_CREDENTIALS"], settings=GeminiTTSService.Settings( model="gemini-2.5-flash-tts", voice="Charon", @@ -64,7 +64,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-google-http.py b/examples/update-settings/tts/tts-google-http.py index b9a605560..eef39d8f8 100644 --- a/examples/update-settings/tts/tts-google-http.py +++ b/examples/update-settings/tts/tts-google-http.py @@ -50,12 +50,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) - tts = GoogleHttpTTSService(credentials=os.getenv("GOOGLE_TEST_CREDENTIALS")) + tts = GoogleHttpTTSService(credentials=os.environ["GOOGLE_TEST_CREDENTIALS"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-google-stream.py b/examples/update-settings/tts/tts-google-stream.py index a1c5129a6..2614022e7 100644 --- a/examples/update-settings/tts/tts-google-stream.py +++ b/examples/update-settings/tts/tts-google-stream.py @@ -50,12 +50,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) - tts = GoogleTTSService(credentials=os.getenv("GOOGLE_TEST_CREDENTIALS")) + tts = GoogleTTSService(credentials=os.environ["GOOGLE_TEST_CREDENTIALS"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-gradium.py b/examples/update-settings/tts/tts-gradium.py index 7498557a9..3750b004a 100644 --- a/examples/update-settings/tts/tts-gradium.py +++ b/examples/update-settings/tts/tts-gradium.py @@ -50,16 +50,16 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = GradiumTTSService( - api_key=os.getenv("GRADIUM_API_KEY"), + api_key=os.environ["GRADIUM_API_KEY"], settings=GradiumTTSService.Settings(voice="YTpq7expH9539ERJ"), url="wss://us.api.gradium.ai/api/speech/tts", ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-groq.py b/examples/update-settings/tts/tts-groq.py index 757276c6a..1926dfa96 100644 --- a/examples/update-settings/tts/tts-groq.py +++ b/examples/update-settings/tts/tts-groq.py @@ -50,12 +50,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) - tts = GroqTTSService(api_key=os.getenv("GROQ_API_KEY")) + tts = GroqTTSService(api_key=os.environ["GROQ_API_KEY"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-hume.py b/examples/update-settings/tts/tts-hume.py index 034ff6797..6399a908a 100644 --- a/examples/update-settings/tts/tts-hume.py +++ b/examples/update-settings/tts/tts-hume.py @@ -50,7 +50,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = HumeTTSService( api_key=os.getenv("HUME_API_KEY"), @@ -58,7 +58,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-inworld-http.py b/examples/update-settings/tts/tts-inworld-http.py index 41b960dd4..28ea6c81d 100644 --- a/examples/update-settings/tts/tts-inworld-http.py +++ b/examples/update-settings/tts/tts-inworld-http.py @@ -54,12 +54,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) - tts = InworldHttpTTSService(api_key=os.getenv("INWORLD_API_KEY"), aiohttp_session=session) + tts = InworldHttpTTSService(api_key=os.environ["INWORLD_API_KEY"], aiohttp_session=session) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-inworld.py b/examples/update-settings/tts/tts-inworld.py index 9f40247dd..9bdd706e5 100644 --- a/examples/update-settings/tts/tts-inworld.py +++ b/examples/update-settings/tts/tts-inworld.py @@ -50,12 +50,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) - tts = InworldTTSService(api_key=os.getenv("INWORLD_API_KEY")) + tts = InworldTTSService(api_key=os.environ["INWORLD_API_KEY"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-kokoro.py b/examples/update-settings/tts/tts-kokoro.py index 8c7e1f492..053dd630b 100644 --- a/examples/update-settings/tts/tts-kokoro.py +++ b/examples/update-settings/tts/tts-kokoro.py @@ -50,7 +50,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = KokoroTTSService( settings=KokoroTTSService.Settings( @@ -59,7 +59,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-lmnt.py b/examples/update-settings/tts/tts-lmnt.py index d700e22c2..68f5f6d12 100644 --- a/examples/update-settings/tts/tts-lmnt.py +++ b/examples/update-settings/tts/tts-lmnt.py @@ -50,15 +50,15 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = LmntTTSService( - api_key=os.getenv("LMNT_API_KEY"), + api_key=os.environ["LMNT_API_KEY"], settings=LmntTTSService.Settings(voice="lily"), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-minimax.py b/examples/update-settings/tts/tts-minimax.py index b77e84554..3a02adce0 100644 --- a/examples/update-settings/tts/tts-minimax.py +++ b/examples/update-settings/tts/tts-minimax.py @@ -52,16 +52,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = MiniMaxHttpTTSService( - api_key=os.getenv("MINIMAX_API_KEY", ""), - group_id=os.getenv("MINIMAX_GROUP_ID", ""), + api_key=os.environ["MINIMAX_API_KEY"], + group_id=os.environ["MINIMAX_GROUP_ID"], aiohttp_session=session, ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-neuphonic-http.py b/examples/update-settings/tts/tts-neuphonic-http.py index 3db9e5d2e..a55d6fd6c 100644 --- a/examples/update-settings/tts/tts-neuphonic-http.py +++ b/examples/update-settings/tts/tts-neuphonic-http.py @@ -51,16 +51,16 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) async with aiohttp.ClientSession() as session: tts = NeuphonicHttpTTSService( - api_key=os.getenv("NEUPHONIC_API_KEY"), + api_key=os.environ["NEUPHONIC_API_KEY"], aiohttp_session=session, ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-neuphonic.py b/examples/update-settings/tts/tts-neuphonic.py index bb10f8699..fd37ec40e 100644 --- a/examples/update-settings/tts/tts-neuphonic.py +++ b/examples/update-settings/tts/tts-neuphonic.py @@ -50,12 +50,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) - tts = NeuphonicTTSService(api_key=os.getenv("NEUPHONIC_API_KEY")) + tts = NeuphonicTTSService(api_key=os.environ["NEUPHONIC_API_KEY"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-nvidia.py b/examples/update-settings/tts/tts-nvidia.py index 2b41e1cdd..e136db033 100644 --- a/examples/update-settings/tts/tts-nvidia.py +++ b/examples/update-settings/tts/tts-nvidia.py @@ -51,12 +51,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) - tts = NvidiaTTSService(api_key=os.getenv("NVIDIA_API_KEY")) + tts = NvidiaTTSService(api_key=os.environ["NVIDIA_API_KEY"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-openai.py b/examples/update-settings/tts/tts-openai.py index c75e56513..e23db32ac 100644 --- a/examples/update-settings/tts/tts-openai.py +++ b/examples/update-settings/tts/tts-openai.py @@ -50,12 +50,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) - tts = OpenAITTSService(api_key=os.getenv("OPENAI_API_KEY")) + tts = OpenAITTSService(api_key=os.environ["OPENAI_API_KEY"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-piper-http.py b/examples/update-settings/tts/tts-piper-http.py index 685f81dd5..ed943b5b0 100644 --- a/examples/update-settings/tts/tts-piper-http.py +++ b/examples/update-settings/tts/tts-piper-http.py @@ -53,16 +53,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = PiperHttpTTSService( - base_url=os.getenv("PIPER_BASE_URL"), + base_url=os.environ["PIPER_BASE_URL"], aiohttp_session=session, settings=PiperHttpTTSService.Settings(voice="en_US-ryan-high"), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-piper.py b/examples/update-settings/tts/tts-piper.py index df10d999a..710a9ad7f 100644 --- a/examples/update-settings/tts/tts-piper.py +++ b/examples/update-settings/tts/tts-piper.py @@ -50,7 +50,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = PiperTTSService( settings=PiperTTSService.Settings( @@ -59,7 +59,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-resembleai.py b/examples/update-settings/tts/tts-resembleai.py index ae295cfa2..3f3a5e271 100644 --- a/examples/update-settings/tts/tts-resembleai.py +++ b/examples/update-settings/tts/tts-resembleai.py @@ -50,15 +50,15 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = ResembleAITTSService( - api_key=os.getenv("RESEMBLE_API_KEY"), - settings=ResembleAITTSService.Settings(voice=os.getenv("RESEMBLE_VOICE_UUID")), + api_key=os.environ["RESEMBLE_API_KEY"], + settings=ResembleAITTSService.Settings(voice=os.environ["RESEMBLE_VOICE_UUID"]), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), @@ -103,7 +103,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info("Updating ResembleAI TTS settings: voice (changed)") await task.queue_frame( TTSUpdateSettingsFrame( - delta=ResembleAITTSService.Settings(voice=os.getenv("RESEMBLE_VOICE_UUID_ALT")) + delta=ResembleAITTSService.Settings(voice=os.environ["RESEMBLE_VOICE_UUID_ALT"]) ) ) diff --git a/examples/update-settings/tts/tts-rime-http.py b/examples/update-settings/tts/tts-rime-http.py index af69dcda5..3e5b2d2e7 100644 --- a/examples/update-settings/tts/tts-rime-http.py +++ b/examples/update-settings/tts/tts-rime-http.py @@ -54,16 +54,16 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = RimeHttpTTSService( - api_key=os.getenv("RIME_API_KEY"), + api_key=os.environ["RIME_API_KEY"], settings=RimeHttpTTSService.Settings(voice="eva"), aiohttp_session=session, ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-rime.py b/examples/update-settings/tts/tts-rime.py index 44bc69e13..314eeeb05 100644 --- a/examples/update-settings/tts/tts-rime.py +++ b/examples/update-settings/tts/tts-rime.py @@ -50,15 +50,15 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = RimeTTSService( - api_key=os.getenv("RIME_API_KEY"), + api_key=os.environ["RIME_API_KEY"], settings=RimeTTSService.Settings(voice="luna"), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-sarvam-http.py b/examples/update-settings/tts/tts-sarvam-http.py index e9a35f8cd..ec6911f5f 100644 --- a/examples/update-settings/tts/tts-sarvam-http.py +++ b/examples/update-settings/tts/tts-sarvam-http.py @@ -54,12 +54,12 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) - tts = SarvamHttpTTSService(api_key=os.getenv("SARVAM_API_KEY"), aiohttp_session=session) + tts = SarvamHttpTTSService(api_key=os.environ["SARVAM_API_KEY"], aiohttp_session=session) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-sarvam.py b/examples/update-settings/tts/tts-sarvam.py index 77bb80d57..9cb24ad93 100644 --- a/examples/update-settings/tts/tts-sarvam.py +++ b/examples/update-settings/tts/tts-sarvam.py @@ -50,12 +50,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) - tts = SarvamTTSService(api_key=os.getenv("SARVAM_API_KEY")) + tts = SarvamTTSService(api_key=os.environ["SARVAM_API_KEY"]) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-speechmatics.py b/examples/update-settings/tts/tts-speechmatics.py index 4cefa1cc8..a4515739c 100644 --- a/examples/update-settings/tts/tts-speechmatics.py +++ b/examples/update-settings/tts/tts-speechmatics.py @@ -51,16 +51,16 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) async with aiohttp.ClientSession() as session: tts = SpeechmaticsTTSService( - api_key=os.getenv("SPEECHMATICS_API_KEY"), + api_key=os.environ["SPEECHMATICS_API_KEY"], aiohttp_session=session, ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/update-settings/tts/tts-xtts.py b/examples/update-settings/tts/tts-xtts.py index b1fb4f309..0145e8c64 100644 --- a/examples/update-settings/tts/tts-xtts.py +++ b/examples/update-settings/tts/tts-xtts.py @@ -53,7 +53,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = XTTSService( aiohttp_session=session, @@ -64,7 +64,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/video-avatar/video-avatar-heygen-transport.py b/examples/video-avatar/video-avatar-heygen-transport.py index 47ec01abd..0ea504520 100644 --- a/examples/video-avatar/video-avatar-heygen-transport.py +++ b/examples/video-avatar/video-avatar-heygen-transport.py @@ -37,7 +37,7 @@ logger.add(sys.stderr, level="DEBUG") async def main(): async with aiohttp.ClientSession() as session: transport = HeyGenTransport( - api_key=os.getenv("HEYGEN_LIVE_AVATAR_API_KEY"), + api_key=os.environ["HEYGEN_LIVE_AVATAR_API_KEY"], service_type=ServiceType.LIVE_AVATAR, session=session, params=HeyGenParams( @@ -52,17 +52,17 @@ async def main(): ), ) - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="00967b2f-88a6-4a31-8153-110a92134b9f", ), ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( system_instruction="You are a helpful assistant. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Be succinct and respond to what the user said in a creative and helpful way.", ), diff --git a/examples/video-avatar/video-avatar-heygen-video-service.py b/examples/video-avatar/video-avatar-heygen-video-service.py index 35d2e3221..a48c42758 100644 --- a/examples/video-avatar/video-avatar-heygen-video-service.py +++ b/examples/video-avatar/video-avatar-heygen-video-service.py @@ -59,24 +59,24 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="00967b2f-88a6-4a31-8153-110a92134b9f", ), ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( system_instruction="You are a helpful assistant. Your output will be spoken aloud, so avoid special characters that can't easily be spoken, such as emojis or bullet points. Be succinct and respond to what the user said in a creative and helpful way.", ), ) heyGen = HeyGenVideoService( - api_key=os.getenv("HEYGEN_LIVE_AVATAR_API_KEY"), + api_key=os.environ["HEYGEN_LIVE_AVATAR_API_KEY"], service_type=ServiceType.LIVE_AVATAR, session=session, session_request=LiveAvatarNewSessionRequest( diff --git a/examples/video-avatar/video-avatar-lemonslice-transport.py b/examples/video-avatar/video-avatar-lemonslice-transport.py index 52cd1ca25..08dd48aa3 100644 --- a/examples/video-avatar/video-avatar-lemonslice-transport.py +++ b/examples/video-avatar/video-avatar-lemonslice-transport.py @@ -41,7 +41,7 @@ async def main(): async with aiohttp.ClientSession() as session: transport = LemonSliceTransport( bot_name="Pipecat", - api_key=os.getenv("LEMONSLICE_API_KEY"), + api_key=os.environ["LEMONSLICE_API_KEY"], session=session, session_request=LemonSliceNewSessionRequest( agent_id=os.getenv("LEMONSLICE_AGENT_ID"), @@ -53,10 +53,10 @@ async def main(): ), ) - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) llm = GroqLLMService( - api_key=os.getenv("GROQ_API_KEY"), + api_key=os.environ["GROQ_API_KEY"], settings=GroqLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/video-avatar/video-avatar-simli-video-service.py b/examples/video-avatar/video-avatar-simli-video-service.py index 76c2dd99d..c91623253 100644 --- a/examples/video-avatar/video-avatar-simli-video-service.py +++ b/examples/video-avatar/video-avatar-simli-video-service.py @@ -56,22 +56,22 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", ), ) simli_ai = SimliVideoService( - api_key=os.getenv("SIMLI_API_KEY"), + api_key=os.environ["SIMLI_API_KEY"], face_id="cace3ef7-a4c4-425d-a8cf-a5358eb0c427", ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/video-avatar/video-avatar-tavus-transport.py b/examples/video-avatar/video-avatar-tavus-transport.py index db19e650e..566538dbb 100644 --- a/examples/video-avatar/video-avatar-tavus-transport.py +++ b/examples/video-avatar/video-avatar-tavus-transport.py @@ -37,8 +37,8 @@ async def main(): async with aiohttp.ClientSession() as session: transport = TavusTransport( bot_name="Pipecat bot", - api_key=os.getenv("TAVUS_API_KEY"), - replica_id=os.getenv("TAVUS_REPLICA_ID"), + api_key=os.environ["TAVUS_API_KEY"], + replica_id=os.environ["TAVUS_REPLICA_ID"], session=session, params=TavusParams( audio_in_enabled=True, @@ -47,17 +47,17 @@ async def main(): ), ) - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="a167e0f3-df7e-4d52-a9c3-f949145efdab", ), ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/video-avatar/video-avatar-tavus-video-service.py b/examples/video-avatar/video-avatar-tavus-video-service.py index 5658951b5..ce3075074 100644 --- a/examples/video-avatar/video-avatar-tavus-video-service.py +++ b/examples/video-avatar/video-avatar-tavus-video-service.py @@ -59,25 +59,25 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="a167e0f3-df7e-4d52-a9c3-f949145efdab", ), ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), ) tavus = TavusVideoService( - api_key=os.getenv("TAVUS_API_KEY"), - replica_id=os.getenv("TAVUS_REPLICA_ID"), + api_key=os.environ["TAVUS_API_KEY"], + replica_id=os.environ["TAVUS_REPLICA_ID"], session=session, ) diff --git a/examples/video-processing/video-processing.py b/examples/video-processing/video-processing.py index 531c7c940..812de5b03 100644 --- a/examples/video-processing/video-processing.py +++ b/examples/video-processing/video-processing.py @@ -96,20 +96,13 @@ Respond to what the user said in a creative and helpful way. Keep your responses async def run_bot(pipecat_transport): llm = GeminiLiveLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], voice_id="Puck", # Aoede, Charon, Fenrir, Kore, Puck transcribe_user_audio=True, system_instruction=SYSTEM_INSTRUCTION, ) - messages = [ - { - "role": "developer", - "content": "Start by greeting the user warmly and introducing yourself.", - } - ] - - context = LLMContext(messages) + context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()), @@ -141,6 +134,12 @@ async def run_bot(pipecat_transport): async def on_client_ready(rtvi): logger.info("Pipecat client ready.") # Kick off the conversation. + context.add_message( + { + "role": "developer", + "content": "Start by greeting the user warmly and introducing yourself.", + } + ) await task.queue_frames([LLMRunFrame()]) @pipecat_transport.event_handler("on_client_connected") diff --git a/examples/vision/vision-anthropic.py b/examples/vision/vision-anthropic.py index 642885dcf..d02cf8b95 100644 --- a/examples/vision/vision-anthropic.py +++ b/examples/vision/vision-anthropic.py @@ -49,17 +49,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = AnthropicLLMService( - api_key=os.getenv("ANTHROPIC_API_KEY"), + api_key=os.environ["ANTHROPIC_API_KEY"], settings=AnthropicLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You are also able to describe images.", ), diff --git a/examples/vision/vision-aws.py b/examples/vision/vision-aws.py index 47d2b7970..8905f1e9f 100644 --- a/examples/vision/vision-aws.py +++ b/examples/vision/vision-aws.py @@ -49,10 +49,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/vision/vision-gemini-flash.py b/examples/vision/vision-gemini-flash.py index 248bc08a7..b94942766 100644 --- a/examples/vision/vision-gemini-flash.py +++ b/examples/vision/vision-gemini-flash.py @@ -49,17 +49,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You are also able to describe images.", ), diff --git a/examples/vision/vision-moondream.py b/examples/vision/vision-moondream.py index 6a73de7b3..5b2a3f2e7 100644 --- a/examples/vision/vision-moondream.py +++ b/examples/vision/vision-moondream.py @@ -41,7 +41,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), diff --git a/examples/vision/vision-openai-responses-http.py b/examples/vision/vision-openai-responses-http.py index 866a86d2c..86c63a266 100644 --- a/examples/vision/vision-openai-responses-http.py +++ b/examples/vision/vision-openai-responses-http.py @@ -49,17 +49,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesHttpLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIResponsesHttpLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You are also able to describe images.", ), diff --git a/examples/vision/vision-openai-responses.py b/examples/vision/vision-openai-responses.py index a3c113cb2..d66c2b2ba 100644 --- a/examples/vision/vision-openai-responses.py +++ b/examples/vision/vision-openai-responses.py @@ -49,17 +49,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIResponsesLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You are also able to describe images.", ), diff --git a/examples/vision/vision-openai.py b/examples/vision/vision-openai.py index 8c8af6352..2dfede380 100644 --- a/examples/vision/vision-openai.py +++ b/examples/vision/vision-openai.py @@ -49,17 +49,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way. You are also able to describe images.", ), diff --git a/examples/voice/voice-aicoustics.py b/examples/voice/voice-aicoustics.py index 16b850052..39110de88 100644 --- a/examples/voice/voice-aicoustics.py +++ b/examples/voice/voice-aicoustics.py @@ -73,17 +73,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-assemblyai-turn-detection.py b/examples/voice/voice-assemblyai-turn-detection.py index 64d257675..26662872e 100644 --- a/examples/voice/voice-assemblyai-turn-detection.py +++ b/examples/voice/voice-assemblyai-turn-detection.py @@ -91,7 +91,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = AssemblyAISTTService( - api_key=os.getenv("ASSEMBLYAI_API_KEY"), + api_key=os.environ["ASSEMBLYAI_API_KEY"], vad_force_turn_endpoint=False, # Use AssemblyAI's built-in turn detection settings=AssemblyAISTTService.Settings( model="u3-rt-pro", @@ -106,14 +106,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-assemblyai.py b/examples/voice/voice-assemblyai.py index 6bcae005a..826b4b020 100644 --- a/examples/voice/voice-assemblyai.py +++ b/examples/voice/voice-assemblyai.py @@ -54,18 +54,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = AssemblyAISTTService( - api_key=os.getenv("ASSEMBLYAI_API_KEY"), + api_key=os.environ["ASSEMBLYAI_API_KEY"], ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-asyncai-http.py b/examples/voice/voice-asyncai-http.py index b861b32ad..480ff9bfd 100644 --- a/examples/voice/voice-asyncai-http.py +++ b/examples/voice/voice-asyncai-http.py @@ -56,7 +56,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create an HTTP session async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = AsyncAIHttpTTSService( api_key=os.getenv("ASYNCAI_API_KEY", ""), @@ -67,7 +67,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-asyncai.py b/examples/voice/voice-asyncai.py index 55daf5e93..46240542c 100644 --- a/examples/voice/voice-asyncai.py +++ b/examples/voice/voice-asyncai.py @@ -53,7 +53,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = AsyncAITTSService( api_key=os.getenv("ASYNCAI_API_KEY", ""), @@ -63,7 +63,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-azure-http.py b/examples/voice/voice-azure-http.py index 6d8206910..c3872cbfb 100644 --- a/examples/voice/voice-azure-http.py +++ b/examples/voice/voice-azure-http.py @@ -53,18 +53,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = AzureSTTService( - api_key=os.getenv("AZURE_SPEECH_API_KEY"), + api_key=os.environ["AZURE_SPEECH_API_KEY"], region=os.getenv("AZURE_SPEECH_REGION"), ) tts = AzureHttpTTSService( - api_key=os.getenv("AZURE_SPEECH_API_KEY"), - region=os.getenv("AZURE_SPEECH_REGION"), + api_key=os.environ["AZURE_SPEECH_API_KEY"], + region=os.environ["AZURE_SPEECH_REGION"], ) llm = AzureLLMService( - api_key=os.getenv("AZURE_CHATGPT_API_KEY"), - endpoint=os.getenv("AZURE_CHATGPT_ENDPOINT"), + api_key=os.environ["AZURE_CHATGPT_API_KEY"], + endpoint=os.environ["AZURE_CHATGPT_ENDPOINT"], settings=AzureLLMService.Settings( model=os.getenv("AZURE_CHATGPT_MODEL"), system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/voice/voice-azure.py b/examples/voice/voice-azure.py index a7977b04b..708c96e18 100644 --- a/examples/voice/voice-azure.py +++ b/examples/voice/voice-azure.py @@ -53,18 +53,18 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = AzureSTTService( - api_key=os.getenv("AZURE_SPEECH_API_KEY"), + api_key=os.environ["AZURE_SPEECH_API_KEY"], region=os.getenv("AZURE_SPEECH_REGION"), ) tts = AzureTTSService( - api_key=os.getenv("AZURE_SPEECH_API_KEY"), - region=os.getenv("AZURE_SPEECH_REGION"), + api_key=os.environ["AZURE_SPEECH_API_KEY"], + region=os.environ["AZURE_SPEECH_REGION"], ) llm = AzureLLMService( - api_key=os.getenv("AZURE_CHATGPT_API_KEY"), - endpoint=os.getenv("AZURE_CHATGPT_ENDPOINT"), + api_key=os.environ["AZURE_CHATGPT_API_KEY"], + endpoint=os.environ["AZURE_CHATGPT_ENDPOINT"], settings=AzureLLMService.Settings( model=os.getenv("AZURE_CHATGPT_MODEL"), system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", diff --git a/examples/voice/voice-camb.py b/examples/voice/voice-camb.py index 90b6cabd4..a84b3c3ec 100644 --- a/examples/voice/voice-camb.py +++ b/examples/voice/voice-camb.py @@ -52,17 +52,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info("Starting Camb AI TTS bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CambTTSService( - api_key=os.getenv("CAMB_API_KEY"), + api_key=os.environ["CAMB_API_KEY"], settings=CambTTSService.Settings( model="mars-flash", ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful voice assistant powered by Camb AI text-to-speech. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Keep responses concise.", ), diff --git a/examples/voice/voice-cartesia-http.py b/examples/voice/voice-cartesia-http.py index 15fe51142..f2f02ec7d 100644 --- a/examples/voice/voice-cartesia-http.py +++ b/examples/voice/voice-cartesia-http.py @@ -54,10 +54,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = CartesiaSTTService(api_key=os.getenv("CARTESIA_API_KEY")) + stt = CartesiaSTTService(api_key=os.environ["CARTESIA_API_KEY"]) tts = CartesiaHttpTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], aiohttp_session=session, settings=CartesiaHttpTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady @@ -65,7 +65,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-cartesia.py b/examples/voice/voice-cartesia.py index 0489663e7..2a399b954 100644 --- a/examples/voice/voice-cartesia.py +++ b/examples/voice/voice-cartesia.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = CartesiaSTTService(api_key=os.getenv("CARTESIA_API_KEY")) + stt = CartesiaSTTService(api_key=os.environ["CARTESIA_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-deepgram-flux-sagemaker.py b/examples/voice/voice-deepgram-flux-sagemaker.py index c203ed43a..c0426ab15 100644 --- a/examples/voice/voice-deepgram-flux-sagemaker.py +++ b/examples/voice/voice-deepgram-flux-sagemaker.py @@ -59,8 +59,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # - AWS credentials configured (via environment variables or AWS CLI) # - A deployed SageMaker endpoint with Deepgram Flux model stt = DeepgramFluxSageMakerSTTService( - endpoint_name=os.getenv("SAGEMAKER_STT_ENDPOINT_NAME"), - region=os.getenv("AWS_REGION"), + endpoint_name=os.environ["SAGEMAKER_STT_ENDPOINT_NAME"], + region=os.environ["AWS_REGION"], settings=DeepgramFluxSageMakerSTTService.Settings( min_confidence=0.3, ), @@ -71,8 +71,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # - AWS credentials configured (via environment variables or AWS CLI) # - A deployed SageMaker endpoint with Deepgram TTS model tts = DeepgramSageMakerTTSService( - endpoint_name=os.getenv("SAGEMAKER_TTS_ENDPOINT_NAME"), - region=os.getenv("AWS_REGION"), + endpoint_name=os.environ["SAGEMAKER_TTS_ENDPOINT_NAME"], + region=os.environ["AWS_REGION"], settings=DeepgramSageMakerTTSService.Settings( voice="aura-2-andromeda-en", ), diff --git a/examples/voice/voice-deepgram-flux.py b/examples/voice/voice-deepgram-flux.py index 76a5bb783..7e9ec3938 100644 --- a/examples/voice/voice-deepgram-flux.py +++ b/examples/voice/voice-deepgram-flux.py @@ -55,21 +55,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = DeepgramFluxSTTService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], settings=DeepgramFluxSTTService.Settings( min_confidence=0.3, ), ) tts = DeepgramTTSService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], settings=DeepgramTTSService.Settings( voice="aura-2-andromeda-en", ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-deepgram-http.py b/examples/voice/voice-deepgram-http.py index c81b2cd2f..d53255ca0 100644 --- a/examples/voice/voice-deepgram-http.py +++ b/examples/voice/voice-deepgram-http.py @@ -55,10 +55,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = DeepgramHttpTTSService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], settings=DeepgramHttpTTSService.Settings( voice="aura-2-andromeda-en", ), @@ -66,7 +66,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-deepgram-sagemaker.py b/examples/voice/voice-deepgram-sagemaker.py index e823f18f9..30e861518 100644 --- a/examples/voice/voice-deepgram-sagemaker.py +++ b/examples/voice/voice-deepgram-sagemaker.py @@ -58,8 +58,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # - AWS credentials configured (via environment variables or AWS CLI) # - A deployed SageMaker endpoint with Deepgram model stt = DeepgramSageMakerSTTService( - endpoint_name=os.getenv("SAGEMAKER_STT_ENDPOINT_NAME"), - region=os.getenv("AWS_REGION"), + endpoint_name=os.environ["SAGEMAKER_STT_ENDPOINT_NAME"], + region=os.environ["AWS_REGION"], ) # Initialize Deepgram SageMaker TTS Service @@ -67,8 +67,8 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # - AWS credentials configured (via environment variables or AWS CLI) # - A deployed SageMaker endpoint with Deepgram TTS model tts = DeepgramSageMakerTTSService( - endpoint_name=os.getenv("SAGEMAKER_TTS_ENDPOINT_NAME"), - region=os.getenv("AWS_REGION"), + endpoint_name=os.environ["SAGEMAKER_TTS_ENDPOINT_NAME"], + region=os.environ["AWS_REGION"], settings=DeepgramSageMakerTTSService.Settings( voice="aura-2-andromeda-en", ), diff --git a/examples/voice/voice-deepgram-vad.py b/examples/voice/voice-deepgram-vad.py deleted file mode 100644 index bbdb01efe..000000000 --- a/examples/voice/voice-deepgram-vad.py +++ /dev/null @@ -1,133 +0,0 @@ -# -# Copyright (c) 2024-2026, Daily -# -# SPDX-License-Identifier: BSD 2-Clause License -# - - -import os - -from dotenv import load_dotenv -from loguru import logger - -from pipecat.frames.frames import LLMRunFrame -from pipecat.pipeline.pipeline import Pipeline -from pipecat.pipeline.runner import PipelineRunner -from pipecat.pipeline.task import PipelineParams, PipelineTask -from pipecat.processors.aggregators.llm_context import LLMContext -from pipecat.processors.aggregators.llm_response_universal import ( - LLMContextAggregatorPair, - LLMUserAggregatorParams, -) -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.transports.base_transport import BaseTransport, TransportParams -from pipecat.transports.daily.transport import DailyParams -from pipecat.transports.websocket.fastapi import FastAPIWebsocketParams -from pipecat.turns.user_turn_strategies import ExternalUserTurnStrategies - -load_dotenv(override=True) - - -# We use lambdas to defer transport parameter creation until the transport -# type is selected at runtime. -transport_params = { - "daily": lambda: DailyParams( - audio_in_enabled=True, - audio_out_enabled=True, - ), - "twilio": lambda: FastAPIWebsocketParams( - audio_in_enabled=True, - audio_out_enabled=True, - ), - "webrtc": lambda: TransportParams( - audio_in_enabled=True, - audio_out_enabled=True, - ), -} - - -async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): - logger.info(f"Starting bot") - - stt = DeepgramSTTService( - api_key=os.getenv("DEEPGRAM_API_KEY"), - settings=DeepgramSTTService.Settings( - vad_events=True, - utterance_end_ms="1000", - ), - ) - - tts = DeepgramTTSService( - api_key=os.getenv("DEEPGRAM_API_KEY"), - settings=DeepgramTTSService.Settings( - voice="aura-2-andromeda-en", - ), - ) - - llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), - settings=OpenAILLMService.Settings( - system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", - ), - ) - - context = LLMContext() - user_aggregator, assistant_aggregator = LLMContextAggregatorPair( - context, - user_params=LLMUserAggregatorParams(user_turn_strategies=ExternalUserTurnStrategies()), - ) - - pipeline = Pipeline( - [ - transport.input(), # Transport user input - stt, # STT - user_aggregator, # User responses - llm, # LLM - tts, # TTS - transport.output(), # Transport bot output - assistant_aggregator, # Assistant spoken responses - ] - ) - - task = PipelineTask( - pipeline, - params=PipelineParams( - enable_metrics=True, - enable_usage_metrics=True, - ), - idle_timeout_secs=runner_args.pipeline_idle_timeout_secs, - ) - - @transport.event_handler("on_client_connected") - async def on_client_connected(transport, client): - logger.info(f"Client connected") - # Kick off the conversation. - context.add_message( - {"role": "developer", "content": "Please introduce yourself to the user."} - ) - await task.queue_frames([LLMRunFrame()]) - - @transport.event_handler("on_client_disconnected") - async def on_client_disconnected(transport, client): - logger.info(f"Client disconnected") - await task.cancel() - - runner = PipelineRunner(handle_sigint=runner_args.handle_sigint) - - await runner.run(task) - - -async def bot(runner_args: RunnerArguments): - """Main bot entry point compatible with Pipecat Cloud.""" - transport = await create_transport(runner_args, transport_params) - await run_bot(transport, runner_args) - - -if __name__ == "__main__": - from pipecat.runner.run import main - - main() diff --git a/examples/voice/voice-deepgram.py b/examples/voice/voice-deepgram.py index bebde3fe3..323fd34a3 100644 --- a/examples/voice/voice-deepgram.py +++ b/examples/voice/voice-deepgram.py @@ -53,17 +53,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = DeepgramTTSService( - api_key=os.getenv("DEEPGRAM_API_KEY"), + api_key=os.environ["DEEPGRAM_API_KEY"], settings=DeepgramTTSService.Settings( voice="aura-2-andromeda-en", ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-elevenlabs-http.py b/examples/voice/voice-elevenlabs-http.py index b9e35ec4f..87e8dc2ca 100644 --- a/examples/voice/voice-elevenlabs-http.py +++ b/examples/voice/voice-elevenlabs-http.py @@ -57,7 +57,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create an HTTP session async with aiohttp.ClientSession() as session: stt = ElevenLabsSTTService( - api_key=os.getenv("ELEVENLABS_API_KEY"), + api_key=os.environ["ELEVENLABS_API_KEY"], aiohttp_session=session, ) @@ -70,7 +70,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-elevenlabs.py b/examples/voice/voice-elevenlabs.py index ebdfdde72..8f61bb665 100644 --- a/examples/voice/voice-elevenlabs.py +++ b/examples/voice/voice-elevenlabs.py @@ -53,7 +53,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = ElevenLabsRealtimeSTTService(api_key=os.getenv("ELEVENLABS_API_KEY")) + stt = ElevenLabsRealtimeSTTService(api_key=os.environ["ELEVENLABS_API_KEY"]) tts = ElevenLabsTTSService( api_key=os.getenv("ELEVENLABS_API_KEY", ""), @@ -63,7 +63,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-fal.py b/examples/voice/voice-fal.py index 5ce43bbe6..d4b1e4a52 100644 --- a/examples/voice/voice-fal.py +++ b/examples/voice/voice-fal.py @@ -61,14 +61,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-fish.py b/examples/voice/voice-fish.py index 5519b6c4f..0ff8503c8 100644 --- a/examples/voice/voice-fish.py +++ b/examples/voice/voice-fish.py @@ -53,17 +53,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = FishAudioTTSService( - api_key=os.getenv("FISH_API_KEY"), + api_key=os.environ["FISH_API_KEY"], settings=FishAudioTTSService.Settings( voice="4ce7e917cedd4bc2bb2e6ff3a46acaa1", # Barack Obama ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-gladia-vad.py b/examples/voice/voice-gladia-vad.py index f29930c3e..c0eea8841 100644 --- a/examples/voice/voice-gladia-vad.py +++ b/examples/voice/voice-gladia-vad.py @@ -55,9 +55,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") + region = os.getenv("GLADIA_REGION", "us-west") + assert region in ("us-west", "eu-west"), f"Invalid GLADIA_REGION: {region}" + stt = GladiaSTTService( - api_key=os.getenv("GLADIA_API_KEY", ""), - region=os.getenv("GLADIA_REGION"), + api_key=os.environ["GLADIA_API_KEY"], + region=region, settings=GladiaSTTService.Settings( language_config=LanguageConfig( languages=[Language.EN], diff --git a/examples/voice/voice-gladia.py b/examples/voice/voice-gladia.py index 3f417bf5a..a6a909a9a 100644 --- a/examples/voice/voice-gladia.py +++ b/examples/voice/voice-gladia.py @@ -54,9 +54,12 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") + region = os.getenv("GLADIA_REGION", "us-west") + assert region in ("us-west", "eu-west"), f"Invalid GLADIA_REGION: {region}" + stt = GladiaSTTService( - api_key=os.getenv("GLADIA_API_KEY", ""), - region=os.getenv("GLADIA_REGION"), + api_key=os.environ["GLADIA_API_KEY"], + region=region, settings=GladiaSTTService.Settings( language_config=LanguageConfig( languages=[Language.EN], diff --git a/examples/voice/voice-google-audio-in.py b/examples/voice/voice-google-audio-in.py index fa314afed..f6a350411 100644 --- a/examples/voice/voice-google-audio-in.py +++ b/examples/voice/voice-google-audio-in.py @@ -215,7 +215,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( model="gemini-2.5-flash", system_instruction=system_message, @@ -230,7 +230,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): language=Language.EN_US, ), params=GoogleTTSService.InputParams(language=Language.EN_US), - credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + credentials=os.environ["GOOGLE_TEST_CREDENTIALS"], ) context = LLMContext() diff --git a/examples/voice/voice-google-gemini-tts.py b/examples/voice/voice-google-gemini-tts.py index 7b995a564..8aa7e3c39 100644 --- a/examples/voice/voice-google-gemini-tts.py +++ b/examples/voice/voice-google-gemini-tts.py @@ -57,11 +57,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): settings=GoogleSTTService.Settings( languages=[Language.EN_US], ), - credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + credentials=os.environ["GOOGLE_TEST_CREDENTIALS"], ) tts = GeminiTTSService( - credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + credentials=os.environ["GOOGLE_TEST_CREDENTIALS"], settings=GeminiTTSService.Settings( model="gemini-2.5-flash-tts", voice="Charon", @@ -71,7 +71,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], model="gemini-2.5-flash", settings=GoogleLLMService.Settings( system_instruction="""You are a helpful assistant in a voice conversation. diff --git a/examples/voice/voice-google-http.py b/examples/voice/voice-google-http.py index d961f2d8d..0e642b8ca 100644 --- a/examples/voice/voice-google-http.py +++ b/examples/voice/voice-google-http.py @@ -59,7 +59,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Add model to use a specific model # model="chirp_3", ), - credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + credentials=os.environ["GOOGLE_TEST_CREDENTIALS"], location="us", ) @@ -68,11 +68,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): voice="en-US-Chirp3-HD-Charon", language=Language.EN_US, ), - credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + credentials=os.environ["GOOGLE_TEST_CREDENTIALS"], ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( model="gemini-2.5-flash", # force a certain amount of thinking if you want it diff --git a/examples/voice/voice-google-image.py b/examples/voice/voice-google-image.py index 80f115390..52949b357 100644 --- a/examples/voice/voice-google-image.py +++ b/examples/voice/voice-google-image.py @@ -67,14 +67,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = GoogleSTTService( - credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + credentials=os.environ["GOOGLE_TEST_CREDENTIALS"], settings=GoogleSTTService.Settings( languages=[Language.EN_US], ), ) tts = GoogleTTSService( - credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + credentials=os.environ["GOOGLE_TEST_CREDENTIALS"], settings=GoogleTTSService.Settings( voice="en-US-Chirp3-HD-Charon", language=Language.EN_US, @@ -82,7 +82,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( model="gemini-2.5-flash-image", # model="gemini-3-pro-image-preview", # A more powerful model, but slower, diff --git a/examples/voice/voice-google.py b/examples/voice/voice-google.py index 10684b8cc..9f6a43874 100644 --- a/examples/voice/voice-google.py +++ b/examples/voice/voice-google.py @@ -59,7 +59,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Add model to use a specific model # model="chirp_3", ), - credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + credentials=os.environ["GOOGLE_TEST_CREDENTIALS"], location="us", ) @@ -68,11 +68,11 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): voice="en-US-Chirp3-HD-Charon", language=Language.EN_US, ), - credentials=os.getenv("GOOGLE_TEST_CREDENTIALS"), + credentials=os.environ["GOOGLE_TEST_CREDENTIALS"], ) llm = GoogleLLMService( - api_key=os.getenv("GOOGLE_API_KEY"), + api_key=os.environ["GOOGLE_API_KEY"], settings=GoogleLLMService.Settings( model="gemini-2.5-flash", # force a certain amount of thinking if you want it diff --git a/examples/voice/voice-gradium.py b/examples/voice/voice-gradium.py index 3573d0b39..89573f48a 100644 --- a/examples/voice/voice-gradium.py +++ b/examples/voice/voice-gradium.py @@ -53,7 +53,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = GradiumSTTService( - api_key=os.getenv("GRADIUM_API_KEY"), + api_key=os.environ["GRADIUM_API_KEY"], api_endpoint_base_url="wss://us.api.gradium.ai/api/speech/asr", settings=GradiumSTTService.Settings( language=Language.EN, @@ -61,7 +61,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = GradiumTTSService( - api_key=os.getenv("GRADIUM_API_KEY"), + api_key=os.environ["GRADIUM_API_KEY"], url="wss://us.api.gradium.ai/api/speech/tts", settings=GradiumTTSService.Settings( voice="YTpq7expH9539ERJ", @@ -69,7 +69,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-groq.py b/examples/voice/voice-groq.py index 7ffa8b06b..9b1b34da4 100644 --- a/examples/voice/voice-groq.py +++ b/examples/voice/voice-groq.py @@ -52,17 +52,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = GroqSTTService(api_key=os.getenv("GROQ_API_KEY")) + stt = GroqSTTService(api_key=os.environ["GROQ_API_KEY"]) llm = GroqLLMService( - api_key=os.getenv("GROQ_API_KEY"), + api_key=os.environ["GROQ_API_KEY"], settings=GroqLLMService.Settings( model="llama-3.1-8b-instant", system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), ) - tts = GroqTTSService(api_key=os.getenv("GROQ_API_KEY")) + tts = GroqTTSService(api_key=os.environ["GROQ_API_KEY"]) context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( diff --git a/examples/voice/voice-hume.py b/examples/voice/voice-hume.py index 2dbeeb924..bda68d6f9 100644 --- a/examples/voice/voice-hume.py +++ b/examples/voice/voice-hume.py @@ -54,7 +54,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = HumeTTSService( api_key=os.getenv("HUME_API_KEY"), @@ -65,7 +65,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-inworld-http.py b/examples/voice/voice-inworld-http.py index 3d06a055a..2a388f62b 100644 --- a/examples/voice/voice-inworld-http.py +++ b/examples/voice/voice-inworld-http.py @@ -53,7 +53,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info("Starting bot") async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = InworldHttpTTSService( api_key=os.getenv("INWORLD_API_KEY", ""), @@ -66,7 +66,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful AI demonstrating Inworld AI's TTS. 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 friendly and helpful way.", ), diff --git a/examples/voice/voice-inworld.py b/examples/voice/voice-inworld.py index 7db6edbee..b8603efc9 100644 --- a/examples/voice/voice-inworld.py +++ b/examples/voice/voice-inworld.py @@ -50,7 +50,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info("Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = InworldTTSService( api_key=os.getenv("INWORLD_API_KEY", ""), @@ -61,7 +61,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful AI demonstrating Inworld AI's TTS. 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 friendly and helpful way.", ), diff --git a/examples/voice/voice-kokoro.py b/examples/voice/voice-kokoro.py index c55c2ba08..fe74589dc 100644 --- a/examples/voice/voice-kokoro.py +++ b/examples/voice/voice-kokoro.py @@ -52,7 +52,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = KokoroTTSService( settings=KokoroTTSService.Settings( @@ -61,7 +61,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-krisp-viva.py b/examples/voice/voice-krisp-viva.py index 06a236e0d..fa6498616 100644 --- a/examples/voice/voice-krisp-viva.py +++ b/examples/voice/voice-krisp-viva.py @@ -84,17 +84,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-langchain.py b/examples/voice/voice-langchain.py index 8ab17aa79..19fda0c91 100644 --- a/examples/voice/voice-langchain.py +++ b/examples/voice/voice-langchain.py @@ -16,7 +16,7 @@ from langchain_openai import ChatOpenAI from loguru import logger from pipecat.audio.vad.silero import SileroVADAnalyzer -from pipecat.frames.frames import LLMMessagesUpdateFrame +from pipecat.frames.frames import LLMRunFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.pipeline.runner import PipelineRunner from pipecat.pipeline.task import PipelineParams, PipelineTask @@ -67,10 +67,10 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), @@ -129,8 +129,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # An `LLMContextFrame` will be picked up by the LangchainProcessor using # only the content of the last message to inject it in the prompt defined # above. So no role is required here. - messages = [({"content": "Please briefly introduce yourself to the user."})] - await task.queue_frames([LLMMessagesUpdateFrame(messages, run_llm=True)]) + context.add_message( + {"role": "developer", "content": "Please briefly introduce yourself to the user."} + ) + await task.queue_frames([LLMRunFrame()]) @transport.event_handler("on_client_disconnected") async def on_client_disconnected(transport, client): diff --git a/examples/voice/voice-lmnt.py b/examples/voice/voice-lmnt.py index 41e42a961..6faa4c31c 100644 --- a/examples/voice/voice-lmnt.py +++ b/examples/voice/voice-lmnt.py @@ -52,17 +52,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = LmntTTSService( - api_key=os.getenv("LMNT_API_KEY"), + api_key=os.environ["LMNT_API_KEY"], settings=LmntTTSService.Settings( voice="morgan", ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-minimax.py b/examples/voice/voice-minimax.py index 92fda761d..9e4291af7 100644 --- a/examples/voice/voice-minimax.py +++ b/examples/voice/voice-minimax.py @@ -57,7 +57,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create an HTTP session async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = MiniMaxHttpTTSService( api_key=os.getenv("MINIMAX_API_KEY", ""), @@ -69,7 +69,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-mistral.py b/examples/voice/voice-mistral.py index 440039b65..4664caf22 100644 --- a/examples/voice/voice-mistral.py +++ b/examples/voice/voice-mistral.py @@ -53,17 +53,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = MistralSTTService(api_key=os.getenv("MISTRAL_API_KEY")) + stt = MistralSTTService(api_key=os.environ["MISTRAL_API_KEY"]) tts = MistralTTSService( - api_key=os.getenv("MISTRAL_API_KEY"), + api_key=os.environ["MISTRAL_API_KEY"], settings=MistralTTSService.Settings( voice="c69964a6-ab8b-4f8a-9465-ec0925096ec8", ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-neuphonic-http.py b/examples/voice/voice-neuphonic-http.py index 6392d4606..9cbcc8ede 100644 --- a/examples/voice/voice-neuphonic-http.py +++ b/examples/voice/voice-neuphonic-http.py @@ -56,10 +56,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create an HTTP session async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = NeuphonicHttpTTSService( - api_key=os.getenv("NEUPHONIC_API_KEY"), + api_key=os.environ["NEUPHONIC_API_KEY"], settings=NeuphonicHttpTTSService.Settings( voice="fc854436-2dac-4d21-aa69-ae17b54e98eb", # Emily ), @@ -67,7 +67,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-neuphonic.py b/examples/voice/voice-neuphonic.py index a0aaf82fa..1ea90fd51 100644 --- a/examples/voice/voice-neuphonic.py +++ b/examples/voice/voice-neuphonic.py @@ -52,17 +52,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = NeuphonicTTSService( - api_key=os.getenv("NEUPHONIC_API_KEY"), + api_key=os.environ["NEUPHONIC_API_KEY"], settings=NeuphonicTTSService.Settings( voice="fc854436-2dac-4d21-aa69-ae17b54e98eb", # Emily ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-nvidia.py b/examples/voice/voice-nvidia.py index b308f71a2..7f84134d3 100644 --- a/examples/voice/voice-nvidia.py +++ b/examples/voice/voice-nvidia.py @@ -52,17 +52,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = NvidiaSTTService(api_key=os.getenv("NVIDIA_API_KEY")) + stt = NvidiaSTTService(api_key=os.environ["NVIDIA_API_KEY"]) llm = NvidiaLLMService( - api_key=os.getenv("NVIDIA_API_KEY"), + api_key=os.environ["NVIDIA_API_KEY"], settings=NvidiaLLMService.Settings( model="meta/llama-3.3-70b-instruct", system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), ) - tts = NvidiaTTSService(api_key=os.getenv("NVIDIA_API_KEY")) + tts = NvidiaTTSService(api_key=os.environ["NVIDIA_API_KEY"]) context = LLMContext() user_aggregator, assistant_aggregator = LLMContextAggregatorPair( diff --git a/examples/voice/voice-openai-http.py b/examples/voice/voice-openai-http.py index 19f1a3e8a..1483acb69 100644 --- a/examples/voice/voice-openai-http.py +++ b/examples/voice/voice-openai-http.py @@ -53,7 +53,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = OpenAISTTService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAISTTService.Settings( model="gpt-4o-transcribe", prompt="Expect words related to dogs, such as breed names.", @@ -61,14 +61,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = OpenAITTSService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAITTSService.Settings( voice="ballad", ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are very knowledgable about dogs. 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/voice/voice-openai-responses-http.py b/examples/voice/voice-openai-responses-http.py index 6960bf7b2..b3f49cbe1 100644 --- a/examples/voice/voice-openai-responses-http.py +++ b/examples/voice/voice-openai-responses-http.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesHttpLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIResponsesHttpLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-openai-responses.py b/examples/voice/voice-openai-responses.py index baae3754a..d1ecc0946 100644 --- a/examples/voice/voice-openai-responses.py +++ b/examples/voice/voice-openai-responses.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAIResponsesLLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIResponsesLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-openai.py b/examples/voice/voice-openai.py index b749ce27a..8f162671f 100644 --- a/examples/voice/voice-openai.py +++ b/examples/voice/voice-openai.py @@ -54,7 +54,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = OpenAIRealtimeSTTService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAIRealtimeSTTService.Settings( model="gpt-4o-transcribe", prompt="Expect words related to dogs, such as breed names.", @@ -63,14 +63,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = OpenAITTSService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAITTSService.Settings( voice="ballad", ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are very knowledgable about dogs. 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/voice/voice-piper.py b/examples/voice/voice-piper.py index 617223ceb..dffdd4d34 100644 --- a/examples/voice/voice-piper.py +++ b/examples/voice/voice-piper.py @@ -52,7 +52,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = PiperTTSService( settings=PiperTTSService.Settings( @@ -61,7 +61,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-resemble.py b/examples/voice/voice-resemble.py index c27ca9255..f3c2a1336 100644 --- a/examples/voice/voice-resemble.py +++ b/examples/voice/voice-resemble.py @@ -51,17 +51,17 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = ResembleAITTSService( - api_key=os.getenv("RESEMBLE_API_KEY"), + api_key=os.environ["RESEMBLE_API_KEY"], settings=ResembleAITTSService.Settings( - voice=os.getenv("RESEMBLE_VOICE_UUID"), + voice=os.environ["RESEMBLE_VOICE_UUID"], ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-rime-http.py b/examples/voice/voice-rime-http.py index 165735d6e..72bc63ca7 100644 --- a/examples/voice/voice-rime-http.py +++ b/examples/voice/voice-rime-http.py @@ -56,7 +56,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create an HTTP session async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = RimeHttpTTSService( api_key=os.getenv("RIME_API_KEY", ""), @@ -69,7 +69,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-rime.py b/examples/voice/voice-rime.py index 07ea429c7..bd1f50dbc 100644 --- a/examples/voice/voice-rime.py +++ b/examples/voice/voice-rime.py @@ -52,7 +52,7 @@ transport_params = { async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = RimeTTSService( api_key=os.getenv("RIME_API_KEY", ""), @@ -62,7 +62,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-sarvam-http.py b/examples/voice/voice-sarvam-http.py index bca27e051..b70f44e2a 100644 --- a/examples/voice/voice-sarvam-http.py +++ b/examples/voice/voice-sarvam-http.py @@ -58,14 +58,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create an HTTP session async with aiohttp.ClientSession() as session: stt = SarvamSTTService( - api_key=os.getenv("SARVAM_API_KEY"), + api_key=os.environ["SARVAM_API_KEY"], settings=SarvamSTTService.Settings( model="saarika:v2.5", ), ) tts = SarvamHttpTTSService( - api_key=os.getenv("SARVAM_API_KEY"), + api_key=os.environ["SARVAM_API_KEY"], aiohttp_session=session, settings=SarvamHttpTTSService.Settings( language=Language.EN_IN, @@ -73,7 +73,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = SarvamLLMService( - api_key=os.getenv("SARVAM_API_KEY"), + api_key=os.environ["SARVAM_API_KEY"], settings=SarvamLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-sarvam.py b/examples/voice/voice-sarvam.py index feda4fe38..5c646d505 100644 --- a/examples/voice/voice-sarvam.py +++ b/examples/voice/voice-sarvam.py @@ -53,21 +53,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = SarvamSTTService( - api_key=os.getenv("SARVAM_API_KEY"), + api_key=os.environ["SARVAM_API_KEY"], settings=SarvamSTTService.Settings( model="saaras:v3", ), ) tts = SarvamTTSService( - api_key=os.getenv("SARVAM_API_KEY"), + api_key=os.environ["SARVAM_API_KEY"], settings=SarvamTTSService.Settings( model="bulbul:v3", voice="shubh", ), ) llm = SarvamLLMService( - api_key=os.getenv("SARVAM_API_KEY"), + api_key=os.environ["SARVAM_API_KEY"], settings=SarvamLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-smallest.py b/examples/voice/voice-smallest.py index f1b3dcf43..b5b82802a 100644 --- a/examples/voice/voice-smallest.py +++ b/examples/voice/voice-smallest.py @@ -52,21 +52,21 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = SmallestSTTService( - api_key=os.getenv("SMALLEST_API_KEY"), + api_key=os.environ["SMALLEST_API_KEY"], settings=SmallestSTTService.Settings( language=Language.EN, ), ) tts = SmallestTTSService( - api_key=os.getenv("SMALLEST_API_KEY"), + api_key=os.environ["SMALLEST_API_KEY"], settings=SmallestTTSService.Settings( voice="sophia", ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( 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/voice/voice-soniox.py b/examples/voice/voice-soniox.py index 857fd19e8..b89106d14 100644 --- a/examples/voice/voice-soniox.py +++ b/examples/voice/voice-soniox.py @@ -52,7 +52,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") stt = SonioxSTTService( - api_key=os.getenv("SONIOX_API_KEY"), + api_key=os.environ["SONIOX_API_KEY"], settings=SonioxSTTService.Settings( # Add language hints to use a specific language # Add strict mode to enforce the language hints @@ -62,14 +62,14 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = CartesiaTTSService( - api_key=os.getenv("CARTESIA_API_KEY"), + api_key=os.environ["CARTESIA_API_KEY"], settings=CartesiaTTSService.Settings( voice="71a7ad14-091c-4e8e-a314-022ece01c121", # British Reading Lady ), ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-speechmatics-vad.py b/examples/voice/voice-speechmatics-vad.py index bcceb4dea..b21bf7156 100644 --- a/examples/voice/voice-speechmatics-vad.py +++ b/examples/voice/voice-speechmatics-vad.py @@ -91,7 +91,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: stt = SpeechmaticsSTTService( - api_key=os.getenv("SPEECHMATICS_API_KEY"), + api_key=os.environ["SPEECHMATICS_API_KEY"], settings=SpeechmaticsSTTService.Settings( language=Language.EN, turn_detection_mode=SpeechmaticsSTTService.TurnDetectionMode.ADAPTIVE, @@ -102,7 +102,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = SpeechmaticsTTSService( - api_key=os.getenv("SPEECHMATICS_API_KEY"), + api_key=os.environ["SPEECHMATICS_API_KEY"], settings=SpeechmaticsTTSService.Settings( voice="sarah", ), @@ -110,7 +110,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( temperature=0.75, system_instruction="You are a helpful British assistant called Sarah in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. 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.", diff --git a/examples/voice/voice-speechmatics.py b/examples/voice/voice-speechmatics.py index d619715aa..3f7fa9ac4 100644 --- a/examples/voice/voice-speechmatics.py +++ b/examples/voice/voice-speechmatics.py @@ -74,7 +74,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"), + api_key=os.environ["SPEECHMATICS_API_KEY"], settings=SpeechmaticsSTTService.Settings( language=Language.EN, speaker_active_format="<{speaker_id}>{text}", @@ -82,7 +82,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) tts = SpeechmaticsTTSService( - api_key=os.getenv("SPEECHMATICS_API_KEY"), + api_key=os.environ["SPEECHMATICS_API_KEY"], settings=SpeechmaticsTTSService.Settings( voice="sarah", ), @@ -90,7 +90,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( temperature=0.75, system_instruction="You are a helpful British assistant called Sarah in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. 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.", diff --git a/examples/voice/voice-xai.py b/examples/voice/voice-xai.py index e7fa04350..833f9b816 100644 --- a/examples/voice/voice-xai.py +++ b/examples/voice/voice-xai.py @@ -53,10 +53,10 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): logger.info(f"Starting bot") async with aiohttp.ClientSession() as session: - stt = XAISTTService(api_key=os.getenv("XAI_API_KEY")) + stt = XAISTTService(api_key=os.environ["XAI_API_KEY"]) tts = XAIHttpTTSService( - api_key=os.getenv("XAI_API_KEY"), + api_key=os.environ["XAI_API_KEY"], aiohttp_session=session, settings=XAIHttpTTSService.Settings( voice="eve", @@ -64,7 +64,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = GrokLLMService( - api_key=os.getenv("XAI_API_KEY"), + api_key=os.environ["XAI_API_KEY"], settings=GrokLLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/examples/voice/voice-xtts.py b/examples/voice/voice-xtts.py index f0bfe01c0..f9d92e45b 100644 --- a/examples/voice/voice-xtts.py +++ b/examples/voice/voice-xtts.py @@ -55,7 +55,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): # Create an HTTP session async with aiohttp.ClientSession() as session: - stt = DeepgramSTTService(api_key=os.getenv("DEEPGRAM_API_KEY")) + stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"]) tts = XTTSService( aiohttp_session=session, @@ -66,7 +66,7 @@ async def run_bot(transport: BaseTransport, runner_args: RunnerArguments): ) llm = OpenAILLMService( - api_key=os.getenv("OPENAI_API_KEY"), + api_key=os.environ["OPENAI_API_KEY"], settings=OpenAILLMService.Settings( system_instruction="You are a helpful assistant in a voice conversation. Your responses will be spoken aloud, so avoid emojis, bullet points, or other formatting that can't be spoken. Respond to what the user said in a creative, helpful, and brief way.", ), diff --git a/pyrightconfig.json b/pyrightconfig.json index 6dae89b0a..94c0114b6 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -13,10 +13,7 @@ "src/pipecat/pipeline", "src/pipecat/runner" ], - "exclude": [ - "**/*_pb2.py", - "**/__pycache__" - ], + "exclude": ["**/*_pb2.py", "**/__pycache__"], "ignore": [ "src/pipecat/adapters", "src/pipecat/audio", @@ -28,7 +25,6 @@ "src/pipecat/transports", "src/pipecat/utils", "tests", - "examples", "scripts", "docs" ],