Features:
- Bilingual support (English/Mandarin Chinese)
- Hotword detection: 'Hey Osiris' / '你好 Osiris'
- Music playback control (MP3, WAV, OGG, FLAC)
- OpenClaw integration for AI responses
- Google AIY Voice Kit V1 compatible
- Text-to-speech in both languages
- Voice command recognition
- Raspberry Pi ready with installation script
AI Now Inc - Del Mar Demo Unit 🏭
186 lines
5.5 KiB
Python
Executable File
186 lines
5.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Test Setup Script
|
|
Verifies all components are working correctly.
|
|
|
|
Run this after installation to ensure everything is configured properly.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
from pathlib import Path
|
|
|
|
print("\n" + "="*70)
|
|
print(" 🧪 Voice Assistant - Setup Test Suite")
|
|
print(" AI Now Inc - Del Mar Demo Unit")
|
|
print("="*70)
|
|
print()
|
|
|
|
# Test counter
|
|
tests_passed = 0
|
|
tests_failed = 0
|
|
|
|
def test_result(name: str, passed: bool, message: str = ""):
|
|
global tests_passed, tests_failed
|
|
status = "✅ PASS" if passed else "❌ FAIL"
|
|
print(f"{status}: {name}")
|
|
if message:
|
|
print(f" → {message}")
|
|
if passed:
|
|
tests_passed += 1
|
|
else:
|
|
tests_failed += 1
|
|
return passed
|
|
|
|
# Test 1: Python version
|
|
print("1. Checking Python version...")
|
|
if sys.version_info >= (3, 8):
|
|
test_result("Python version", True, f"Python {sys.version}")
|
|
else:
|
|
test_result("Python version", False, f"Need Python 3.8+, have {sys.version}")
|
|
|
|
# Test 2: Required packages
|
|
print("\n2. Checking required packages...")
|
|
required_packages = [
|
|
"pygame",
|
|
"requests",
|
|
"websocket-client",
|
|
"langdetect",
|
|
"mutagen"
|
|
]
|
|
|
|
for pkg in required_packages:
|
|
try:
|
|
__import__(pkg.replace("-", "_"))
|
|
test_result(f"Package: {pkg}", True)
|
|
except ImportError:
|
|
test_result(f"Package: {pkg}", False, f"Install with: pip install {pkg}")
|
|
|
|
# Test 3: Optional packages
|
|
print("\n3. Checking optional packages...")
|
|
optional_packages = [
|
|
("pvporcupine", "Hotword detection"),
|
|
("webrtcvad", "Voice activity detection"),
|
|
("google.cloud.speech", "Google Cloud Speech"),
|
|
("google.cloud.texttospeech", "Google Cloud TTS")
|
|
]
|
|
|
|
for pkg, desc in optional_packages:
|
|
try:
|
|
__import__(pkg.replace("-", "_").replace(".", "."))
|
|
test_result(f"Optional: {pkg} ({desc})", True)
|
|
except ImportError:
|
|
test_result(f"Optional: {pkg} ({desc})", False, f"Optional - {pkg}")
|
|
|
|
# Test 4: Configuration files
|
|
print("\n4. Checking configuration...")
|
|
config_files = ["config.json", "hotword_config.json"]
|
|
for config_file in config_files:
|
|
if Path(config_file).exists():
|
|
test_result(f"Config: {config_file}", True)
|
|
else:
|
|
test_result(f"Config: {config_file}", False, "File not found")
|
|
|
|
# Test 5: Audio devices
|
|
print("\n5. Checking audio devices...")
|
|
try:
|
|
import pyaudio
|
|
pa = pyaudio.PyAudio()
|
|
device_count = pa.get_device_info()
|
|
test_result("PyAudio", True, f"Found {device_count.get('index', 0)+1} audio devices")
|
|
|
|
# Try to get default input device
|
|
try:
|
|
default_input = pa.get_default_input_device_info()
|
|
test_result("Default input device", True, default_input.get('name', 'Unknown'))
|
|
except:
|
|
test_result("Default input device", False, "No input device found")
|
|
|
|
# Try to get default output device
|
|
try:
|
|
default_output = pa.get_default_output_device_info()
|
|
test_result("Default output device", True, default_output.get('name', 'Unknown'))
|
|
except:
|
|
test_result("Default output device", False, "No output device found")
|
|
|
|
pa.terminate()
|
|
except ImportError:
|
|
test_result("PyAudio", False, "Install with: pip install pyaudio")
|
|
except Exception as e:
|
|
test_result("PyAudio", False, str(e))
|
|
|
|
# Test 6: Music directory
|
|
print("\n6. Checking music directory...")
|
|
music_path = Path("/home/pi/Music")
|
|
if music_path.exists():
|
|
test_result("Music directory", True, str(music_path))
|
|
# Count files
|
|
music_files = list(music_path.glob("**/*.mp3"))
|
|
test_result("Music files", True, f"Found {len(music_files)} MP3 files")
|
|
else:
|
|
test_result("Music directory", False, "Directory not found")
|
|
|
|
# Test 7: Module imports
|
|
print("\n7. Testing module imports...")
|
|
modules = [
|
|
"speech_recognizer",
|
|
"music_player",
|
|
"tts_engine",
|
|
"assistant",
|
|
"hotword_detector",
|
|
"openclaw_client"
|
|
]
|
|
|
|
for module in modules:
|
|
try:
|
|
__import__(module)
|
|
test_result(f"Module: {module}", True)
|
|
except ImportError as e:
|
|
test_result(f"Module: {module}", False, str(e))
|
|
except Exception as e:
|
|
test_result(f"Module: {module}", False, f"Error: {e}")
|
|
|
|
# Test 8: Component initialization
|
|
print("\n8. Testing component initialization...")
|
|
try:
|
|
from assistant import VoiceAssistant
|
|
assistant = VoiceAssistant()
|
|
test_result("VoiceAssistant", True)
|
|
except Exception as e:
|
|
test_result("VoiceAssistant", False, str(e))
|
|
|
|
try:
|
|
from tts_engine import TTSEngine
|
|
tts = TTSEngine()
|
|
test_result("TTSEngine", True)
|
|
except Exception as e:
|
|
test_result("TTSEngine", False, str(e))
|
|
|
|
try:
|
|
from music_player import MusicPlayer
|
|
player = MusicPlayer()
|
|
test_result("MusicPlayer", True, f"Library: {len(player.music_library)} tracks")
|
|
except Exception as e:
|
|
test_result("MusicPlayer", False, str(e))
|
|
|
|
# Summary
|
|
print("\n" + "="*70)
|
|
print(f" Test Summary: {tests_passed} passed, {tests_failed} failed")
|
|
print("="*70)
|
|
|
|
if tests_failed == 0:
|
|
print("\n✅ All tests passed! System is ready to use.")
|
|
print("\nNext steps:")
|
|
print(" 1. Add MP3 files to /home/pi/Music")
|
|
print(" 2. Configure OpenClaw connection in config.json")
|
|
print(" 3. Run: ./start.sh")
|
|
print(" 4. Say 'Hey Osiris' to activate!")
|
|
elif tests_failed > 0:
|
|
print(f"\n⚠️ {tests_failed} test(s) failed. Please fix the issues above.")
|
|
print("\nCommon fixes:")
|
|
print(" - Missing packages: pip install -r requirements.txt")
|
|
print(" - No audio device: Check microphone/speaker connections")
|
|
print(" - Config missing: Copy config.json to config.local.json")
|
|
|
|
print()
|