Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/avatar_audio_passthrough.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ async def interactive_loop(session, display: VideoDisplay) -> None:
AgentAudioInputConfig(encoding="pcm_s16le", sample_rate=24000, channels=1)
)
await send_audio_file_chunked(agent, wav_path)
# When TTS audio is finished, signal end of sequence to the backend
# to let the avatar go back to listening mode
await agent.end_sequence()
else:
print(f"❌ File not found: {wav_file}")

Expand Down
18 changes: 12 additions & 6 deletions examples/persona_interactive_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
export ANAM_AVATAR_ID="your-avatar-id"
export ANAM_VOICE_ID="your-voice-id"
export ANAM_LLM_ID="your-llm-id"
export ANAM_AVATAR_MODEL="model-name" # optional, e.g. "cara-3"
export ANAM_AVATAR_MODEL="model-name" # optional, e.g. "cara-3"
uv run --extra display python examples/persona_interactive_video.py
"""

Expand Down Expand Up @@ -79,7 +79,9 @@ async def interactive_loop(session, display: VideoDisplay) -> None:
print("Available commands:")
print(" m <message> - Send text message (user input for the conversation.)")
print(" t <text> - Send talk command (bypasses LLM and sends text to TTS) using REST API)")
print(" ts <text> - Send talk stream (bypasses LLM and sends text to TTS) using WebSocket (lower latency)")
print(
" ts <text> - Send talk stream (bypasses LLM and sends text to TTS) using WebSocket (lower latency)"
)
print(" i - Interrupt current audio")
print(" c - Toggle live captions. Default: disabled")
print(" h - Toggle conversation history at session end. Default: disabled.")
Expand Down Expand Up @@ -128,7 +130,9 @@ async def interactive_loop(session, display: VideoDisplay) -> None:
elif command == "t" or command == "ts":
# Get the rest of the input as the talk (stream) command
if len(parts) < 2:
print("❌ Please provide talk (stream) command. Usage: t|ts <text to be spoken>")
print(
"❌ Please provide talk (stream) command. Usage: t|ts <text to be spoken>"
)
continue
message_text = " ".join(parts[1:])
try:
Expand Down Expand Up @@ -281,12 +285,14 @@ def main() -> None:
avatar_id = os.environ.get("ANAM_AVATAR_ID", "").strip().strip('"')
voice_id = os.environ.get("ANAM_VOICE_ID", "").strip().strip('"')
avatar_model = os.environ.get("ANAM_AVATAR_MODEL")
llm_id = os.environ.get("ANAM_LLM_ID","").strip().strip('"')
llm_id = os.environ.get("ANAM_LLM_ID", "").strip().strip('"')
api_base_url = os.environ.get("ANAM_API_BASE_URL", "https://api.anam.ai").strip().strip('"')

if not api_key or not avatar_id or not voice_id:
if not api_key or not avatar_id or not llm_id or not voice_id:
# These are required for an ephemeral persona configuration.
raise ValueError("Set ANAM_API_KEY, ANAM_AVATAR_ID, ANAM_LLM_ID and ANAM_VOICE_ID environment variables")
raise ValueError(
"Set ANAM_API_KEY, ANAM_AVATAR_ID, ANAM_LLM_ID and ANAM_VOICE_ID environment variables"
)

system_prompt = "You are a helpful and creative assistant. Respond in a conversational tone with short sentences and do not use special characters or emojis. Start you first message with 'Hello developer, Welcome to Anam. What can I help you with today?'"

Expand Down
1 change: 0 additions & 1 deletion examples/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ async def send_audio_file_chunked(
# Small delay between chunks
await asyncio.sleep(0.01)

await agent.end_sequence()
print(f"✅ Sent {chunk_count} audio chunks from {wav_file_path.name}")


Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading