## Performance Optimizations (3-10x faster responses) - STT beam_size reduced to 1 (3-5x faster transcription, minimal quality loss) - Smart query routing: Haiku (simple) → Sonnet (medium) → Opus (complex) - TTS cache for common phrases (27 pre-generated responses) - Sentence-level streaming TTS (start playing while generating) - Sample-based VAD timing (30x improvement in silence detection) ## TTS Engine Upgrade - Migrated from Chatterbox to Chatterbox-Turbo - Zero-shot voice cloning (no fine-tuning required) - Native paralinguistic tag support ([laugh], [sigh], [chuckle], etc.) - Emotion presets with temperature control - Improved marker conversion (*action*, (action), ~action~) ## Discord Bot Enhancements - Multi-agent support (Jarvis, Sage) - Improved voice receiving with discord-ext-voice-recv - Enhanced /join, /leave, /status commands - Per-agent personality configuration - Better audio sink/receiver implementation ## OpenClaw Integration - WebSocket support for Gateway communication - Query complexity routing (auto-select model) - Improved error handling and retries - Session management per Discord guild - Better latency tracking ## Pipeline Improvements - Sentence splitter for streaming optimization - Query router for intelligent model selection - Enhanced VAD receiver with sample-based timing - Improved audio buffering and format conversion - Better transcript management ## Documentation - Added QUICK_START.md (5-minute test guide) - Added OPTIMIZATION_SUMMARY.md (performance analysis) - Added DISCORD_OPTIMIZATION_TEST.md (testing guide) - Added USAGE_GUIDE.md (comprehensive usage) - Updated README.md with optimization details ## Utilities & Scripts - Added get_invite_link.py (Discord bot invite) - Added sync_commands.py, sync_to_guild.py (command sync) - Added test_gateway.py, test_stt.py (testing utilities) - Added openclaw_wrapper.py (wrapper script) - Removed create_mock_turn_model.py (no longer needed) ## Configuration Updates - STT model: medium → small (faster, acceptable quality) - TTS engine: chatterbox → coqui (Turbo integration) - Beam size: 5 → 1 (latency optimization) - Added emotion_exaggeration per agent - Updated .gitignore for project files Total: ~2105 insertions, ~462 deletions across 35 files Performance: ~5.5s total latency (down from 22-35s) Target: ~3.5s (achieved in simple queries with cache) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
110 lines
3.2 KiB
Python
110 lines
3.2 KiB
Python
"""Test OpenClaw Gateway connection."""
|
|
|
|
import asyncio
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Add project root to path
|
|
import sys
|
|
sys.path.insert(0, str(Path(__file__).parent))
|
|
|
|
from openclaw_client import create_client
|
|
from dotenv import load_dotenv
|
|
|
|
# Load environment variables
|
|
load_dotenv()
|
|
|
|
|
|
async def test_gateway_connection():
|
|
"""Test OpenClaw Gateway connection."""
|
|
print("=" * 70)
|
|
print("OpenClaw Gateway Connection Test")
|
|
print("=" * 70)
|
|
print()
|
|
|
|
# Get credentials from environment
|
|
base_url = os.getenv("OPENCLAW_BASE_URL", "ws://192.168.50.9:18789")
|
|
auth_token = os.getenv("OPENCLAW_AUTH_TOKEN")
|
|
agent_id = os.getenv("OPENCLAW_AGENT_ID", "main")
|
|
|
|
print(f"Gateway URL: {base_url}")
|
|
print(f"Agent ID: {agent_id}")
|
|
print(f"Auth Token: {'***' + auth_token[-4:] if auth_token else 'None'}")
|
|
print()
|
|
|
|
try:
|
|
# Create client
|
|
print("Creating OpenClaw client...")
|
|
client = create_client(
|
|
base_url=base_url,
|
|
auth_token=auth_token,
|
|
agent_id=agent_id,
|
|
timeout=8.0,
|
|
)
|
|
print("[OK] Client created")
|
|
print()
|
|
|
|
# Connect to Gateway
|
|
print("Connecting to Gateway...")
|
|
await client.connect()
|
|
print("[OK] Connected to Gateway")
|
|
print()
|
|
|
|
# Test message for Jarvis
|
|
print("Sending test message to Jarvis agent...")
|
|
response = await client.send_message(
|
|
agent="jarvis",
|
|
message="Hello, this is a test from openclaw-voice. Please respond briefly.",
|
|
speaker="test_user_123",
|
|
)
|
|
print(f"[OK] Received response from Jarvis:")
|
|
# Encode to ASCII, replacing Unicode characters with '?'
|
|
print(f" {response.encode('ascii', 'replace').decode('ascii')}")
|
|
print()
|
|
|
|
# Test message for Sage
|
|
print("Sending test message to Sage agent...")
|
|
response = await client.send_message(
|
|
agent="sage",
|
|
message="Hello Sage, this is a test. Please respond briefly.",
|
|
speaker="test_user_456",
|
|
)
|
|
print(f"[OK] Received response from Sage:")
|
|
# Encode to ASCII, replacing Unicode characters with '?'
|
|
print(f" {response.encode('ascii', 'replace').decode('ascii')}")
|
|
print()
|
|
|
|
# Get stats
|
|
stats = client.get_stats()
|
|
print("Client Statistics:")
|
|
print(f" Total requests: {stats['total_requests']}")
|
|
print(f" Success rate: {stats['success_rate'] * 100:.1f}%")
|
|
print(f" Avg latency: {stats['avg_latency']:.2f}s")
|
|
print(f" Connected: {stats['connected']}")
|
|
print()
|
|
|
|
# Disconnect
|
|
print("Disconnecting from Gateway...")
|
|
await client.disconnect()
|
|
print("[OK] Disconnected")
|
|
print()
|
|
|
|
print("=" * 70)
|
|
print("SUCCESS: ALL TESTS PASSED!")
|
|
print("=" * 70)
|
|
return True
|
|
|
|
except Exception as e:
|
|
print()
|
|
print("=" * 70)
|
|
print("FAILED: TEST FAILED!")
|
|
print("=" * 70)
|
|
print(f"Error: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
|
|
if __name__ == "__main__":
|
|
success = asyncio.run(test_gateway_connection())
|
|
sys.exit(0 if success else 1)
|