Spaces:
Sleeping
Sleeping
| """ | |
| Quick setup and verification script for Voice AI Scheduling Agent | |
| Run this to check if everything is configured correctly. | |
| """ | |
| import os | |
| import sys | |
| from pathlib import Path | |
| print("=" * 70) | |
| print("🎙️ Voice AI Scheduling Agent - Setup Verification") | |
| print("=" * 70) | |
| print() | |
| # Color codes for terminal output | |
| class Colors: | |
| GREEN = '\033[92m' | |
| RED = '\033[91m' | |
| YELLOW = '\033[93m' | |
| BLUE = '\033[94m' | |
| END = '\033[0m' | |
| def check(name, condition, message=""): | |
| """Check a condition and print status.""" | |
| if condition: | |
| print(f"{Colors.GREEN}✓{Colors.END} {name}") | |
| return True | |
| else: | |
| print(f"{Colors.RED}✗{Colors.END} {name}") | |
| if message: | |
| print(f" → {Colors.YELLOW}{message}{Colors.END}") | |
| return False | |
| def check_warning(name, condition, message=""): | |
| """Check with warning (not critical).""" | |
| if condition: | |
| print(f"{Colors.GREEN}✓{Colors.END} {name}") | |
| else: | |
| print(f"{Colors.YELLOW}⚠{Colors.END} {name}") | |
| if message: | |
| print(f" → {message}") | |
| # Check Python version | |
| print(f"{Colors.BLUE}Checking Python Environment...{Colors.END}") | |
| python_version = sys.version_info | |
| check( | |
| "Python 3.8+", | |
| python_version >= (3, 8), | |
| f"Current version: {python_version.major}.{python_version.minor}. Please upgrade to Python 3.8+." | |
| ) | |
| print() | |
| # Check required packages | |
| print(f"{Colors.BLUE}Checking Python Packages...{Colors.END}") | |
| packages = { | |
| "gradio": "Web interface", | |
| "anthropic": "Claude API", | |
| "faster_whisper": "Speech-to-Text", | |
| "google.oauth2": "Google authentication", | |
| "googleapiclient": "Google Calendar API", | |
| "dateparser": "Date parsing", | |
| "numpy": "Audio processing" | |
| } | |
| missing_packages = [] | |
| for package, description in packages.items(): | |
| try: | |
| if package == "google.oauth2": | |
| __import__("google.oauth2") | |
| elif package == "googleapiclient": | |
| __import__("googleapiclient.discovery") | |
| else: | |
| __import__(package) | |
| check(f"{package:20s} ({description})", True) | |
| except ImportError: | |
| check(f"{package:20s} ({description})", False, "Not installed") | |
| missing_packages.append(package) | |
| if missing_packages: | |
| print(f"\n{Colors.YELLOW}To install missing packages:{Colors.END}") | |
| print(f"pip install -r requirements.txt") | |
| print() | |
| # Check environment variables | |
| print(f"{Colors.BLUE}Checking Environment Variables...{Colors.END}") | |
| # Load .env if exists | |
| env_file = Path(".env") | |
| if env_file.exists(): | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| print(f"{Colors.GREEN}✓{Colors.END} .env file found") | |
| else: | |
| print(f"{Colors.YELLOW}⚠{Colors.END} .env file not found") | |
| print(f" → Create .env from .env.example") | |
| # Check API keys | |
| anthropic_key = os.getenv("ANTHROPIC_API_KEY") | |
| check( | |
| "ANTHROPIC_API_KEY", | |
| anthropic_key is not None and anthropic_key != "your_anthropic_api_key_here", | |
| "Get from https://console.anthropic.com/" | |
| ) | |
| # Check Google credentials | |
| google_creds = ( | |
| os.getenv("GOOGLE_CREDENTIALS_PATH") or | |
| os.getenv("GOOGLE_CREDENTIALS_BASE64") or | |
| os.getenv("GOOGLE_CREDENTIALS_JSON") or | |
| os.getenv("GOOGLE_APPLICATION_CREDENTIALS") | |
| ) | |
| check_warning( | |
| "Google Calendar Credentials", | |
| google_creds is not None, | |
| "Set GOOGLE_CREDENTIALS_PATH or alternative. Get from https://console.cloud.google.com/" | |
| ) | |
| # Check credentials file | |
| creds_file = Path("credentials.json") | |
| check_warning( | |
| "credentials.json file", | |
| creds_file.exists(), | |
| "Download from Google Cloud Console and place in project root" | |
| ) | |
| print() | |
| # Check system dependencies | |
| print(f"{Colors.BLUE}Checking System Dependencies...{Colors.END}") | |
| import subprocess | |
| def check_command(cmd, name): | |
| """Check if a command exists.""" | |
| try: | |
| result = subprocess.run( | |
| [cmd, "-version"], | |
| capture_output=True, | |
| text=True, | |
| timeout=5 | |
| ) | |
| check(name, result.returncode == 0) | |
| return True | |
| except (FileNotFoundError, subprocess.TimeoutExpired): | |
| check(name, False, f"Install {name} from official website") | |
| return False | |
| check_command("ffmpeg", "FFmpeg (audio processing)") | |
| check_warning( | |
| "Piper TTS (optional)", | |
| check_command("piper", "Piper"), | |
| "Optional: pip install piper-tts or download binary" | |
| ) | |
| print() | |
| # Check project structure | |
| print(f"{Colors.BLUE}Checking Project Structure...{Colors.END}") | |
| required_dirs = ["services", "utils", "models", "models/whisper", "models/piper"] | |
| for dir_name in required_dirs: | |
| dir_path = Path(dir_name) | |
| check(f"Directory: {dir_name}", dir_path.exists()) | |
| required_files = [ | |
| "app_new.py", | |
| "requirements.txt", | |
| ".env.example", | |
| "services/__init__.py", | |
| "services/stt_service.py", | |
| "services/tts_service.py", | |
| "services/llm_service.py", | |
| "services/calendar_service.py", | |
| "utils/__init__.py", | |
| "utils/audio_utils.py", | |
| "utils/date_parser.py" | |
| ] | |
| for file_name in required_files: | |
| file_path = Path(file_name) | |
| check(f"File: {file_name}", file_path.exists()) | |
| print() | |
| # Try to initialize services | |
| print(f"{Colors.BLUE}Testing Service Initialization...{Colors.END}") | |
| # Check for Piper TTS models | |
| try: | |
| from utils.download_models import ModelDownloader | |
| downloader = ModelDownloader() | |
| downloaded_models = downloader.list_downloaded_models() | |
| if "en_US-lessac-medium" in downloaded_models: | |
| check("Piper TTS Voice Models", True) | |
| else: | |
| check_warning( | |
| "Piper TTS Voice Models", | |
| False, | |
| "Run: python utils/download_models.py to download" | |
| ) | |
| except Exception as e: | |
| check_warning("Piper TTS Voice Models", False, str(e)) | |
| try: | |
| from services.stt_service import get_stt_service | |
| stt = get_stt_service(model_size="tiny") # Use tiny for quick test | |
| check("STT Service (Faster-Whisper)", True) | |
| except Exception as e: | |
| check("STT Service (Faster-Whisper)", False, str(e)) | |
| try: | |
| from services.tts_service import get_tts_service | |
| tts = get_tts_service() | |
| check("TTS Service (Piper)", True) | |
| except Exception as e: | |
| check_warning("TTS Service (Piper)", False, str(e)) | |
| try: | |
| from services.llm_service import get_llm_service | |
| if anthropic_key and anthropic_key != "your_anthropic_api_key_here": | |
| llm = get_llm_service() | |
| check("LLM Service (Claude)", True) | |
| else: | |
| check("LLM Service (Claude)", False, "API key not configured") | |
| except Exception as e: | |
| check("LLM Service (Claude)", False, str(e)) | |
| try: | |
| from services.calendar_service import get_calendar_service | |
| if google_creds: | |
| calendar = get_calendar_service() | |
| check("Calendar Service (Google)", True) | |
| else: | |
| check("Calendar Service (Google)", False, "Credentials not configured") | |
| except Exception as e: | |
| check_warning("Calendar Service (Google)", False, str(e)) | |
| print() | |
| print("=" * 70) | |
| print(f"{Colors.BLUE}Setup Verification Complete!{Colors.END}") | |
| print("=" * 70) | |
| print() | |
| # Final recommendations | |
| print(f"{Colors.BLUE}Next Steps:{Colors.END}") | |
| print() | |
| print("1. If any checks failed:") | |
| print(" - Install missing packages: pip install -r requirements.txt") | |
| print(" - Set up environment variables in .env file") | |
| print(" - Install system dependencies (ffmpeg)") | |
| print(" - Download TTS models: python utils/download_models.py") | |
| print() | |
| print("2. Once all green checkmarks:") | |
| print(" - Run the application: python app_new.py") | |
| print(" - Visit http://localhost:7860") | |
| print() | |
| print("3. For deployment to HuggingFace Spaces:") | |
| print(" - See README_NEW.md for detailed instructions") | |
| print() | |
| print(f"{Colors.GREEN}Good luck with your Voice AI Scheduling Agent! 🎙️{Colors.END}") | |