File size: 7,755 Bytes
c3986c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
"""
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}")