diff --git a/main/xiaozhi-server/test_api_key.py b/main/xiaozhi-server/test_api_key.py deleted file mode 100644 index 7aacbb858..000000000 --- a/main/xiaozhi-server/test_api_key.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env python3 -""" -Test OpenWeatherMap API key -""" - -import os -import sys -import requests -from dotenv import load_dotenv - -# Load environment variables from .env file -load_dotenv() - - -def test_api_key(): - """Test if the OpenWeatherMap API key is working""" - print("๐Ÿ”‘ Testing OpenWeatherMap API Key ๐Ÿ”‘\n") - - # Get API key from environment - api_key = os.getenv('WEATHER_API') - - print(f"API Key from environment: {api_key}") - - if not api_key or api_key == "your_actual_api_key_here": - print("โŒ API key not set properly") - return False - - # Test the API key with a simple request - print(f"๐Ÿงช Testing API key: {api_key[:8]}...{api_key[-4:]}") - - try: - url = "https://api.openweathermap.org/data/2.5/weather" - params = { - "q": "Mumbai", - "appid": api_key, - "units": "metric" - } - - response = requests.get(url, params=params, timeout=10) - - if response.status_code == 200: - data = response.json() - city = data["name"] - temp = data["main"]["temp"] - desc = data["weather"][0]["description"] - - print("โœ… API key is working!") - print(f"๐Ÿ“ Test result: {city} - {temp}ยฐC, {desc}") - return True - - elif response.status_code == 401: - print("โŒ API key is invalid (401 Unauthorized)") - print(" Please check your OpenWeatherMap API key") - return False - - else: - print( - f"โŒ API request failed with status code: {response.status_code}") - print(f" Response: {response.text}") - return False - - except Exception as e: - print(f"โŒ Error testing API key: {e}") - return False - - -def test_env_loading(): - """Test environment variable loading""" - print("\n๐Ÿ”ง Testing Environment Variable Loading ๐Ÿ”ง\n") - - # Test direct environment access - direct_key = os.getenv('WEATHER_API') - print(f"Direct os.getenv('WEATHER_API'): {direct_key}") - - # Test with dotenv - load_dotenv() - dotenv_key = os.getenv('WEATHER_API') - print(f"After load_dotenv(): {dotenv_key}") - - # Check .env file content - try: - with open('.env', 'r') as f: - env_content = f.read() - print(f"\n.env file content:") - for line in env_content.split('\n'): - if 'WEATHER_API' in line: - print(f" {line}") - except Exception as e: - print(f"Error reading .env file: {e}") - - -if __name__ == "__main__": - test_env_loading() - success = test_api_key() - - if success: - print("\n๐ŸŽ‰ Your OpenWeatherMap API key is working correctly!") - print(" The weather service should work now.") - else: - print("\nโŒ API key test failed.") - print(" Please check:") - print(" 1. Your API key is correct") - print(" 2. The API key is active (new keys may take a few minutes)") - print(" 3. You have API calls remaining in your quota") diff --git a/main/xiaozhi-server/test_complete_news_system.py b/main/xiaozhi-server/test_complete_news_system.py deleted file mode 100644 index 8b81ed749..000000000 --- a/main/xiaozhi-server/test_complete_news_system.py +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env python3 -""" -Test complete news system for Indian users -""" - -import sys -import os -sys.path.append('.') - - -def test_complete_news_system(): - """Test all news systems""" - print("๐ŸŒŸ Testing Complete News System for Indian Users ๐ŸŒŸ\n") - - try: - # Test Indian News API - print("1. ๐Ÿ‡ฎ๐Ÿ‡ณ Testing Indian News API...") - from plugins_func.functions.get_indian_news_api import ( - get_indian_news_api, - fetch_indian_news_from_api, - SAMPLE_INDIAN_NEWS - ) - from plugins_func.register import ActionResponse - - # Mock connection - class MockConnection: - def __init__(self): - self.config = { - "plugins": { - "get_indian_news_api": { - "lang": "en_US" - } - } - } - - conn = MockConnection() - - # Test Indian news - result = get_indian_news_api( - conn, category="general", detail=False, lang="en_US") - if isinstance(result, ActionResponse): - print("โœ… Indian News API working!") - print(f"๐Ÿ“„ Sample: {result.result[:150]}...") - else: - print("โŒ Indian News API failed") - - # Test International News - print("\n2. ๐ŸŒ Testing International News...") - from plugins_func.functions.get_news_from_newsnow import get_news_from_newsnow - - # Mock connection with newsnow config - conn.config["plugins"]["get_news_from_newsnow"] = { - "news_sources": "Wall Street Journal;Hacker News;BBC News" - } - - result = get_news_from_newsnow( - conn, source="Wall Street Journal", detail=False, lang="en_US") - if isinstance(result, ActionResponse): - print("โœ… International News working!") - print(f"๐Ÿ“„ Sample: {result.result[:150]}...") - else: - print("โŒ International News failed") - - return True - - except Exception as e: - print(f"โŒ Error: {e}") - import traceback - traceback.print_exc() - return False - - -def show_final_configuration(): - """Show the final recommended configuration""" - print("\n๐ŸŽฏ Final Configuration for Indian Users ๐ŸŽฏ\n") - - print("โœ… ENABLED News Functions:") - print(" โ€ข get_indian_news_api - Primary Indian news source") - print(" โ€ข get_news_from_newsnow - International news backup") - print(" โ€ข get_weather - Weather information") - - print("\n๐Ÿ“ฐ Available News Categories:") - print(" โ€ข General Indian news") - print(" โ€ข Business & Economy") - print(" โ€ข Technology & Startups") - print(" โ€ข Science & Education") - print(" โ€ข International news") - - print("\n๐Ÿ—ฃ๏ธ Voice Commands You Can Use:") - print(" โ€ข 'What's the latest Indian news?'") - print(" โ€ข 'Show me Indian business news'") - print(" โ€ข 'Get technology news from India'") - print(" โ€ข 'Tell me about Indian startups'") - print(" โ€ข 'What's happening in international news?'") - print(" โ€ข 'Get Wall Street Journal news'") - - print("\nโš™๏ธ Configuration Status:") - print(" โ€ข โœ… Indian News API: Enabled with sample data") - print(" โ€ข โœ… International News: Enabled") - print(" โ€ข โœ… Weather Service: Enabled for Bangalore") - print(" โ€ข โŒ Chinese News: Disabled (not relevant for Indian users)") - - print("\n๐Ÿš€ Next Steps to Enhance:") - print(" 1. Get free NewsAPI key: https://newsapi.org/") - print(" 2. Get free GNews key: https://gnews.io/") - print(" 3. Add API keys to config for real-time news") - print(" 4. Test voice commands with your device") - - -if __name__ == "__main__": - success = test_complete_news_system() - - if success: - print("\n๐ŸŽ‰ Complete News System Test Passed!") - show_final_configuration() - - print("\nโœจ Your Xiaozhi server is now optimized for Indian users!") - print( - "The system will provide relevant Indian news alongside international updates.") - - else: - print("\nโŒ Some tests failed, but basic functionality should still work") - show_final_configuration() diff --git a/main/xiaozhi-server/test_english_only.py b/main/xiaozhi-server/test_english_only.py deleted file mode 100644 index 358f63db5..000000000 --- a/main/xiaozhi-server/test_english_only.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env python3 -""" -Test English-only responses -""" - -import sys -sys.path.append('.') - - -def test_english_responses(): - """Test that all functions return English responses""" - print("๐Ÿ‡บ๐Ÿ‡ธ Testing English-Only Responses ๐Ÿ‡บ๐Ÿ‡ธ\n") - - try: - # Mock connection - class MockConnection: - def __init__(self): - self.config = { - "plugins": { - "get_indian_news_api": {"lang": "en_US"}, - "get_news_from_newsnow": { - "news_sources": "Wall Street Journal;Hacker News;BBC News" - } - } - } - - conn = MockConnection() - - # Test Indian News API - print("1. ๐Ÿ‡ฎ๐Ÿ‡ณ Testing Indian News API (English)...") - from plugins_func.functions.get_indian_news_api import get_indian_news_api - result = get_indian_news_api( - conn, category="general", detail=False, lang="en_US") - - if result and hasattr(result, 'result'): - response = result.result - print(f"โœ… Response received: {len(response)} characters") - print(f"๐Ÿ“„ Preview: {response[:200]}...") - - # Check for Chinese characters - chinese_chars = any('\u4e00' <= char <= - '\u9fff' for char in response) - if chinese_chars: - print("โŒ WARNING: Chinese characters detected!") - else: - print("โœ… No Chinese characters found") - - # Test International News - print("\n2. ๐ŸŒ Testing International News (English)...") - from plugins_func.functions.get_news_from_newsnow import get_news_from_newsnow - result = get_news_from_newsnow( - conn, source="Wall Street Journal", detail=False, lang="en_US") - - if result and hasattr(result, 'result'): - response = result.result - print(f"โœ… Response received: {len(response)} characters") - print(f"๐Ÿ“„ Preview: {response[:200]}...") - - # Check for Chinese characters - chinese_chars = any('\u4e00' <= char <= - '\u9fff' for char in response) - if chinese_chars: - print("โŒ WARNING: Chinese characters detected!") - else: - print("โœ… No Chinese characters found") - - return True - - except Exception as e: - print(f"โŒ Error: {e}") - import traceback - traceback.print_exc() - return False - - -def show_language_fixes(): - """Show what was fixed""" - print("\n๐Ÿ”ง Language Fixes Applied ๐Ÿ”ง\n") - - print("โœ… FIXED Issues:") - print(" 1. News functions now default to 'en_US' instead of 'zh_CN'") - print(" 2. ASR configured to prefer English language") - print(" 3. Chinese news function disabled to prevent Chinese responses") - print(" 4. International news defaults to English sources") - - print("\n๐Ÿ“ Configuration Changes:") - print(" โ€ข get_news_from_newsnow: lang='en_US' (was 'zh_CN')") - print(" โ€ข get_news_from_chinanews: lang='en_US' (was 'zh_CN')") - print(" โ€ข ASR: Added English language preference") - print(" โ€ข Intent: Disabled Chinese news function") - - print("\n๐ŸŽฏ Expected Behavior:") - print(" โ€ข All responses should now be in English") - print(" โ€ข News will come from English sources") - print(" โ€ข Speech recognition will prefer English") - print(" โ€ข No more Chinese responses") - - -if __name__ == "__main__": - success = test_english_responses() - show_language_fixes() - - if success: - print("\n๐ŸŽ‰ English-only configuration is working!") - print("Your Xiaozhi should now respond only in English.") - else: - print("\nโš ๏ธ Some issues detected, but main fixes are applied.") - print("Try restarting your Xiaozhi server to apply changes.") diff --git a/main/xiaozhi-server/test_indian_changes.py b/main/xiaozhi-server/test_indian_changes.py deleted file mode 100644 index ae792f1be..000000000 --- a/main/xiaozhi-server/test_indian_changes.py +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/env python3 -""" -Test script for Indian localization changes -""" - -import sys -import os -sys.path.append(os.path.dirname(os.path.abspath(__file__))) - - -def test_ip_location(): - """Test IP location detection with Indian service""" - print("=== Testing IP Location Detection ===") - - from core.utils.util import get_ip_info - from config.logger import setup_logging - - logger = setup_logging() - - # Test with a known Indian IP (example) - test_ips = [ - "103.21.58.66", # Example Indian IP - "8.8.8.8", # Google DNS (should show US) - "", # Empty IP (should use local) - ] - - for ip in test_ips: - try: - result = get_ip_info(ip, logger) - print(f"IP: {ip} -> Location: {result}") - except Exception as e: - print(f"Error testing IP {ip}: {e}") - print() - - -def test_indian_time(): - """Test Indian Standard Time""" - print("=== Testing Indian Standard Time ===") - - from core.utils.prompt_manager import PromptManager - from config.logger import setup_logging - - logger = setup_logging() - config = {} # Minimal config for testing - - pm = PromptManager(config, logger) - - try: - today_date, today_weekday, indian_date = pm._get_current_time_info() - print(f"Today's Date: {today_date}") - print(f"Weekday: {today_weekday}") - print(f"Indian Calendar: {indian_date}") - except Exception as e: - print(f"Error testing time: {e}") - print() - - -def test_indian_calendar(): - """Test Indian calendar function""" - print("=== Testing Indian Calendar Function ===") - - try: - from plugins_func.functions.get_time import get_lunar - - # Test current date - result = get_lunar() - print("Current Date Result:") - print(result.result) - print() - - # Test specific date - result = get_lunar(date="2025-01-15", - query="Vikram Samvat year and Hindu month") - print("Specific Date Result:") - print(result.result) - - except Exception as e: - print(f"Error testing Indian calendar: {e}") - print() - - -def test_prompt_building(): - """Test enhanced prompt building""" - print("=== Testing Enhanced Prompt Building ===") - - from core.utils.prompt_manager import PromptManager - from config.logger import setup_logging - - logger = setup_logging() - config = {} - - pm = PromptManager(config, logger) - - try: - user_prompt = "You are a helpful AI assistant." - device_id = "test_device_123" - client_ip = "103.21.58.66" # Example Indian IP - - # First update context - pm.update_context_info( - type('MockConn', (), {'config': config})(), client_ip) - - # Then build enhanced prompt - enhanced = pm.build_enhanced_prompt(user_prompt, device_id, client_ip) - - print("Enhanced Prompt Preview (first 500 chars):") - print(enhanced[:500] + "..." if len(enhanced) > 500 else enhanced) - - except Exception as e: - print(f"Error testing prompt building: {e}") - print() - - -if __name__ == "__main__": - print("๐Ÿ‡ฎ๐Ÿ‡ณ Testing Indian Localization Changes ๐Ÿ‡ฎ๐Ÿ‡ณ\n") - - # Install required dependency if not present - try: - import pytz - print("โœ… pytz is installed") - except ImportError: - print("โŒ pytz not installed. Please run: pip install pytz") - sys.exit(1) - - print() - - # Run tests - test_ip_location() - test_indian_time() - test_indian_calendar() - test_prompt_building() - - print("๐ŸŽ‰ Testing completed!") diff --git a/main/xiaozhi-server/test_real_api.py b/main/xiaozhi-server/test_real_api.py deleted file mode 100644 index ad37e8fa1..000000000 --- a/main/xiaozhi-server/test_real_api.py +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env python3 -""" -Test with the actual API key from .env file -""" - -import os -import sys -import requests - - -def test_with_real_key(): - """Test with the API key directly from .env file""" - print("๐Ÿ”‘ Testing with Real API Key from .env file ๐Ÿ”‘\n") - - # Read API key directly from .env file - api_key = None - try: - with open('.env', 'r') as f: - for line in f: - if line.startswith('WEATHER_API='): - api_key = line.split('=', 1)[1].strip() - break - except Exception as e: - print(f"Error reading .env file: {e}") - return False - - if not api_key: - print("โŒ Could not find WEATHER_API in .env file") - return False - - print(f"๐Ÿ“‹ API Key from .env file: {api_key[:8]}...{api_key[-4:]}") - - # Test the API key - try: - url = "https://api.openweathermap.org/data/2.5/weather" - params = { - "q": "Mumbai", - "appid": api_key, - "units": "metric" - } - - print("๐Ÿงช Testing API call to OpenWeatherMap...") - response = requests.get(url, params=params, timeout=10) - - print(f"๐Ÿ“Š Response status: {response.status_code}") - - if response.status_code == 200: - data = response.json() - city = data["name"] - temp = data["main"]["temp"] - desc = data["weather"][0]["description"] - - print("โœ… API key is working perfectly!") - print(f"๐Ÿ“ Mumbai weather: {temp}ยฐC, {desc}") - - # Test with an Indian city - params["q"] = "Delhi" - response2 = requests.get(url, params=params, timeout=10) - if response2.status_code == 200: - data2 = response2.json() - print( - f"๐Ÿ“ Delhi weather: {data2['main']['temp']}ยฐC, {data2['weather'][0]['description']}") - - return True - - elif response.status_code == 401: - print("โŒ API key is invalid (401 Unauthorized)") - print(" This might mean:") - print(" 1. The API key is incorrect") - print(" 2. The API key is not activated yet (can take a few minutes)") - print(" 3. The API key has exceeded its quota") - return False - - elif response.status_code == 429: - print("โŒ Too many requests (429)") - print(" You've exceeded the API rate limit") - return False - - else: - print(f"โŒ Unexpected response: {response.status_code}") - print(f" Response: {response.text[:200]}") - return False - - except Exception as e: - print(f"โŒ Error testing API: {e}") - return False - - -def update_weather_function(): - """Update the weather function to use the correct API key""" - print("\n๐Ÿ”ง Updating Weather Function ๐Ÿ”ง\n") - - # Read the actual API key from .env - api_key = None - try: - with open('.env', 'r') as f: - for line in f: - if line.startswith('WEATHER_API='): - api_key = line.split('=', 1)[1].strip() - break - except Exception as e: - print(f"Error reading .env file: {e}") - return - - if not api_key: - print("โŒ Could not find API key in .env file") - return - - print( - f"๐Ÿ“ Will update weather function to use key: {api_key[:8]}...{api_key[-4:]}") - - # Update the get_openweather_api_key function to use the correct key - try: - with open('plugins_func/functions/get_weather.py', 'r') as f: - content = f.read() - - # Replace the fallback key with the actual key - old_line = 'return "your_openweathermap_api_key_here"' - new_line = f'return "{api_key}"' - - if old_line in content: - content = content.replace(old_line, new_line) - - with open('plugins_func/functions/get_weather.py', 'w') as f: - f.write(content) - - print("โœ… Weather function updated with your API key") - return True - else: - print("โŒ Could not find the line to replace in weather function") - return False - - except Exception as e: - print(f"โŒ Error updating weather function: {e}") - return False - - -if __name__ == "__main__": - # Test the API key - success = test_with_real_key() - - if success: - print("\n๐ŸŽ‰ Your API key is working!") - - # Update the weather function - if update_weather_function(): - print("\nโœ… Weather service is now ready to use!") - print(" You can test it by running the server and asking for weather") - - else: - print("\nโŒ API key test failed.") - print("\n๐Ÿ” Troubleshooting steps:") - print("1. Check if your API key is correct in the .env file") - print("2. Make sure the API key is activated (new keys take 10-15 minutes)") - print("3. Verify you haven't exceeded your API quota") - print("4. Try generating a new API key from OpenWeatherMap dashboard") diff --git a/main/xiaozhi-server/test_server_indian.py b/main/xiaozhi-server/test_server_indian.py deleted file mode 100644 index 90c6d4604..000000000 --- a/main/xiaozhi-server/test_server_indian.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env python3 -""" -Test the Indian changes with a mock server connection -""" - -import sys -import os -sys.path.append(os.path.dirname(os.path.abspath(__file__))) - - -def test_full_integration(): - """Test full integration with mock connection""" - print("=== Testing Full Integration ===") - - from core.utils.prompt_manager import PromptManager - from config.logger import setup_logging - - logger = setup_logging() - - # Mock configuration - config = { - "prompt": "You are Arjun, a helpful AI assistant from India. You understand Indian culture and traditions.", - "plugins": { - "get_weather": { - "api_host": "api.openweathermap.org", - "api_key": "demo_key", - "default_location": "Mumbai" - } - } - } - - # Create prompt manager - pm = PromptManager(config, logger) - - # Mock connection object - class MockConnection: - def __init__(self): - self.config = config - - mock_conn = MockConnection() - - # Test with Indian IP - indian_ip = "103.21.58.66" # Mumbai IP - device_id = "test_indian_device" - - try: - # Update context info - pm.update_context_info(mock_conn, indian_ip) - - # Build enhanced prompt - enhanced_prompt = pm.build_enhanced_prompt( - config["prompt"], - device_id, - indian_ip - ) - - print("โœ… Enhanced Prompt Generated Successfully!") - print(f"๐Ÿ“ Length: {len(enhanced_prompt)} characters") - - # Extract key sections - lines = enhanced_prompt.split('\n') - - print("\n๐Ÿ” Key Information Extracted:") - for line in lines: - if 'Current Time:' in line or 'Today\'s Date:' in line or 'Today\'s Indian Calendar:' in line or 'User\'s City:' in line: - print(f" {line.strip()}") - - # Test the get_lunar function directly - print("\n๐Ÿ“… Testing Indian Calendar Function:") - from plugins_func.functions.get_time import get_lunar - - result = get_lunar() - calendar_info = result.result - - # Extract key calendar info - for line in calendar_info.split('\n'): - if 'Gregorian Date:' in line or 'Vikram Samvat Year:' in line or 'Hindu Month:' in line or 'Indian Standard Time:' in line: - print(f" {line.strip()}") - - return True - - except Exception as e: - print(f"โŒ Error in full integration test: {e}") - return False - - -def test_context_variables(): - """Test that context variables are properly set""" - print("\n=== Testing Context Variables ===") - - from core.utils.prompt_manager import PromptManager - from config.logger import setup_logging - - logger = setup_logging() - config = {"prompt": "Test prompt"} - pm = PromptManager(config, logger) - - # Test time info - today_date, today_weekday, indian_date = pm._get_current_time_info() - - print(f"๐Ÿ“… Today's Date: {today_date}") - print(f"๐Ÿ“† Weekday: {today_weekday}") - print(f"๐Ÿ‡ฎ๐Ÿ‡ณ Indian Calendar: {indian_date}") - - # Test location info - test_ip = "103.21.58.66" # Mumbai IP - location = pm._get_location_info(test_ip) - print(f"๐Ÿ“ Location for {test_ip}: {location}") - - return True - - -if __name__ == "__main__": - print("๐Ÿ‡ฎ๐Ÿ‡ณ Testing Indian Localization - Full Integration ๐Ÿ‡ฎ๐Ÿ‡ณ\n") - - success1 = test_context_variables() - success2 = test_full_integration() - - if success1 and success2: - print("\n๐ŸŽ‰ All tests passed! Your Indian localization is working correctly!") - print("\n๐Ÿ“‹ Summary of Changes:") - print(" โœ… Location detection using Indian-friendly IP service") - print(" โœ… Indian Standard Time (IST) timezone") - print(" โœ… Vikram Samvat calendar with Hindu months") - print(" โœ… Enhanced prompt template integration") - print("\n๐Ÿš€ Ready to test with real server!") - else: - print("\nโŒ Some tests failed. Please check the errors above.") diff --git a/main/xiaozhi-server/test_siliconflow_tts.py b/main/xiaozhi-server/test_siliconflow_tts.py deleted file mode 100644 index 3c1f92b0d..000000000 --- a/main/xiaozhi-server/test_siliconflow_tts.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env python3 -""" -Test script for SiliconFlow CosyVoice TTS Provider -""" - -import sys -import os -import asyncio -import yaml - -# Add the main directory to Python path -sys.path.append(os.path.join(os.path.dirname(__file__), 'main', 'xiaozhi-server')) - -from core.providers.tts.siliconflow import TTSProvider - -def load_config(): - """Load configuration from .config.yaml""" - # Try different possible paths - possible_paths = [ - os.path.join(os.path.dirname(__file__), 'data', '.config.yaml'), - os.path.join(os.path.dirname(__file__), 'main', 'xiaozhi-server', 'data', '.config.yaml'), - 'data/.config.yaml' - ] - - for config_path in possible_paths: - try: - with open(config_path, 'r', encoding='utf-8') as f: - config = yaml.safe_load(f) - print(f"โœ… Loaded config from: {config_path}") - return config.get('TTS', {}).get('siliconflow', {}) - except Exception: - continue - - print("Warning: Could not load config from any expected location") - return {} - -async def test_siliconflow_tts(): - """Test SiliconFlow TTS with diana voice""" - - # Load configuration from .config.yaml - config = load_config() - - # Fallback configuration if config file not found - if not config: - config = { - "model": "FunAudioLLM/CosyVoice2-0.5B", - "access_token": "sk-kuyamprtzyvtetbnsyoysbbxuwqzyraldecobjetvdeowzte", # Replace with actual token - "response_format": "mp3", - "speed": 1, - "gain": 0, - "output_dir": "tmp/" - } - - try: - # Initialize TTS provider - tts_provider = TTSProvider(config, delete_audio_file=False) - - # Test text - test_text = "Hello, this is a test of SiliconFlow CosyVoice TTS with Diana voice." - - # Generate speech - output_file = "test_diana_voice.mp3" - print(f"Generating speech for: {test_text}") - print(f"Using voice: {tts_provider.voice or 'Default (model-based)'}") - print(f"Using model: {tts_provider.model}") - - await tts_provider.text_to_speak(test_text, output_file) - - if os.path.exists(output_file): - print(f"โœ… Success! Audio file generated: {output_file}") - print(f"File size: {os.path.getsize(output_file)} bytes") - else: - print("โŒ Failed to generate audio file") - - # Test available voices - voices = tts_provider.get_available_voices() - print(f"\nAvailable voices: {voices}") - - except Exception as e: - print(f"โŒ Error: {e}") - -if __name__ == "__main__": - print("Testing SiliconFlow CosyVoice TTS Provider...") - print("Note: You need to set a valid SiliconFlow access token in the config") - asyncio.run(test_siliconflow_tts()) \ No newline at end of file diff --git a/main/xiaozhi-server/test_ten_vad_linux.py b/main/xiaozhi-server/test_ten_vad_linux.py deleted file mode 100644 index fe29877c6..000000000 --- a/main/xiaozhi-server/test_ten_vad_linux.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python3 -"""Test TEN VAD ONNX installation on Linux""" - -import os -import sys -import platform -from pathlib import Path - -print(f"Platform: {platform.system()} {platform.machine()}") -print(f"Python: {sys.version}") - -# Add the model path to sys.path -model_path = Path("models/ten-vad-onnx") -print(f"Model path: {model_path.absolute()}") - -# Check if files exist -ten_vad_py = model_path / "ten_vad.py" -lib_so = model_path / "lib" / "Linux" / "x64" / "libten_vad.so" -lib_so_alt = model_path / "ten_vad_library" / "libten_vad.so" - -print(f"\nFile checks:") -print(f"ten_vad.py exists: {ten_vad_py.exists()}") -print(f"libten_vad.so (main) exists: {lib_so.exists()}") -print(f"libten_vad.so (alt) exists: {lib_so_alt.exists()}") - -# Set library path -os.environ['LD_LIBRARY_PATH'] = f"{lib_so.parent}:{lib_so_alt.parent}:{os.environ.get('LD_LIBRARY_PATH', '')}" -print(f"\nLD_LIBRARY_PATH: {os.environ['LD_LIBRARY_PATH']}") - -# Try to import -sys.path.insert(0, str(model_path)) -try: - print("\nAttempting to import ten_vad...") - from ten_vad import TenVad - print("โœ… Successfully imported TenVad") - - # Try to create instance - vad = TenVad(hop_size=256, threshold=0.5) - print("โœ… Successfully created TenVad instance") - -except Exception as e: - print(f"โŒ Import failed: {e}") - import traceback - traceback.print_exc() \ No newline at end of file diff --git a/main/xiaozhi-server/test_vad_reset.py b/main/xiaozhi-server/test_vad_reset.py deleted file mode 100644 index c7dee13e9..000000000 --- a/main/xiaozhi-server/test_vad_reset.py +++ /dev/null @@ -1,153 +0,0 @@ -"""Test script to verify VAD state reset functionality.""" - -import numpy as np -import time -from collections import deque - -# Mock connection class for testing -class MockConnection: - def __init__(self): - self.client_audio_buffer = bytearray() - self.client_voice_window = deque(maxlen=5) - self.last_is_voice = False - self.client_have_voice = False - self.last_activity_time = 0.0 - self.client_voice_stop = False - self.vad = None - - def reset_vad_states(self): - """Reset VAD states including internal provider states.""" - self.client_audio_buffer = bytearray() - self.client_have_voice = False - self.client_voice_stop = False - # Reset VAD provider internal states - if hasattr(self, 'vad') and self.vad is not None: - self.vad.reset() - - -def test_vad_reset(): - """Test VAD state reset functionality.""" - - print("Testing VAD State Reset Functionality...") - - # Test configuration - config = { - "model_dir": "models/snakers4_silero-vad", - "threshold": "0.5", - "min_silence_duration_ms": "1000", - "frame_window_threshold": 3, - "start_secs": "0.2", - "stop_secs": "0.8", - "min_volume": "0.6" - } - - try: - from core.providers.vad.silero import VADProvider - from core.providers.vad.vad_analyzer import VADState - - # Create VAD provider - print("\n1. Creating VAD provider...") - vad = VADProvider(config) - - # Create mock connection - conn = MockConnection() - conn.vad = vad - - # Check initial state - if hasattr(vad, 'analyzer'): - print(f" Initial VAD state: {vad.analyzer._vad_state.name}") - print(f" Initial buffer size: {len(vad.analyzer._vad_buffer)}") - - # Simulate some audio processing to change state - print("\n2. Processing some audio to change state...") - # Generate test audio with voice (non-zero values) - voice_audio = (np.random.randn(512) * 1000).astype(np.int16).tobytes() - - # Process multiple frames to potentially change state - for i in range(5): - state = vad.analyzer.analyze_audio(voice_audio) - print(f" Frame {i+1}: State = {state.name}") - - # Check state after processing - print(f"\n3. State after processing: {vad.analyzer._vad_state.name}") - print(f" Buffer size: {len(vad.analyzer._vad_buffer)}") - print(f" Starting count: {vad.analyzer._vad_starting_count}") - print(f" Stopping count: {vad.analyzer._vad_stopping_count}") - - # Reset VAD states - print("\n4. Resetting VAD states...") - conn.reset_vad_states() - - # Check state after reset - print(f"\n5. State after reset: {vad.analyzer._vad_state.name}") - print(f" Buffer size: {len(vad.analyzer._vad_buffer)}") - print(f" Starting count: {vad.analyzer._vad_starting_count}") - print(f" Stopping count: {vad.analyzer._vad_stopping_count}") - - # Verify reset worked - if (vad.analyzer._vad_state == VADState.QUIET and - len(vad.analyzer._vad_buffer) == 0 and - vad.analyzer._vad_starting_count == 0 and - vad.analyzer._vad_stopping_count == 0): - print("\nโœ“ VAD state reset successful!") - else: - print("\nโœ— VAD state reset failed!") - - else: - print("โœ— ONNX VAD not loaded (using PyTorch fallback)") - - except Exception as e: - print(f"โœ— Error during testing: {e}") - import traceback - traceback.print_exc() - - -def test_model_state_reset(): - """Test that model states are also reset.""" - - print("\n\nTesting Model State Reset...") - - try: - from core.providers.vad.silero_onnx import SileroOnnxModel - import os - - model_path = "models/snakers4_silero-vad/src/silero_vad/data/silero_vad.onnx" - - if not os.path.exists(model_path): - print(f"โœ— ONNX model not found at: {model_path}") - return - - # Create model - model = SileroOnnxModel(model_path) - - # Check initial state - print(f"1. Initial model state shape: {model._state.shape}") - print(f" Initial context shape: {model._context.shape}") - - # Process some audio to change state - audio = np.random.randn(512).astype(np.float32) - result = model(audio, 16000) - - print(f"\n2. After processing:") - print(f" State shape: {model._state.shape}") - print(f" Context shape: {model._context.shape}") - - # Reset states - model.reset_states() - - print(f"\n3. After reset:") - print(f" State shape: {model._state.shape}") - print(f" Context shape: {model._context.shape}") - print(f" State is zeros: {np.allclose(model._state, 0)}") - - print("\nโœ“ Model state reset test completed!") - - except Exception as e: - print(f"โœ— Error testing model reset: {e}") - import traceback - traceback.print_exc() - - -if __name__ == "__main__": - test_vad_reset() - test_model_state_reset() \ No newline at end of file diff --git a/main/xiaozhi-server/test_vad_state_transitions.py b/main/xiaozhi-server/test_vad_state_transitions.py deleted file mode 100644 index c40490823..000000000 --- a/main/xiaozhi-server/test_vad_state_transitions.py +++ /dev/null @@ -1,161 +0,0 @@ -"""Test VAD state transitions and reset with realistic audio.""" - -import numpy as np -import time -from core.providers.vad.vad_analyzer import VADState, VADParams - -def test_vad_state_transitions(): - """Test VAD state transitions with loud audio.""" - - print("Testing VAD State Transitions with Loud Audio...") - - try: - from core.providers.vad.silero_onnx import SileroVADAnalyzer - import os - - model_path = "models/snakers4_silero-vad/src/silero_vad/data/silero_vad.onnx" - - if not os.path.exists(model_path): - print(f"โœ— ONNX model not found at: {model_path}") - return - - # Create analyzer with lower thresholds for testing - params = VADParams( - confidence=0.3, # Lower confidence threshold - start_secs=0.1, # Faster start - stop_secs=0.2, # Faster stop - min_volume=0.1 # Lower volume threshold - ) - - analyzer = SileroVADAnalyzer( - model_path=model_path, - sample_rate=16000, - params=params - ) - - print(f"Initial state: {analyzer._vad_state.name}") - - # Generate loud "voice" audio (high amplitude sine wave) - print("\n1. Testing with loud audio (simulated voice)...") - frequency = 440 # A4 note - duration_samples = 512 - t = np.linspace(0, duration_samples/16000, duration_samples) - # Generate loud sine wave (80% of max amplitude) - loud_audio = (0.8 * 32767 * np.sin(2 * np.pi * frequency * t)).astype(np.int16).tobytes() - - # Process multiple frames of loud audio - for i in range(10): - state = analyzer.analyze_audio(loud_audio) - print(f" Frame {i+1}: State = {state.name}, " + - f"Starting count = {analyzer._vad_starting_count}, " + - f"Stopping count = {analyzer._vad_stopping_count}") - if state == VADState.SPEAKING: - print(" โœ“ Voice detected!") - break - - # Now test with silence - print("\n2. Testing with silence...") - silent_audio = np.zeros(512, dtype=np.int16).tobytes() - - for i in range(10): - state = analyzer.analyze_audio(silent_audio) - print(f" Frame {i+1}: State = {state.name}, " + - f"Starting count = {analyzer._vad_starting_count}, " + - f"Stopping count = {analyzer._vad_stopping_count}") - if state == VADState.QUIET: - print(" โœ“ Silence detected!") - break - - # Check final state - print(f"\n3. Final state before reset: {analyzer._vad_state.name}") - - # Reset - print("\n4. Resetting analyzer...") - analyzer.reset() - - print(f" State after reset: {analyzer._vad_state.name}") - print(f" All counters zero: {analyzer._vad_starting_count == 0 and analyzer._vad_stopping_count == 0}") - - # Test that it works again after reset - print("\n5. Testing detection works after reset...") - state = analyzer.analyze_audio(loud_audio) - print(f" First frame after reset: {state.name}") - - print("\nโœ“ State transition test completed!") - - except Exception as e: - print(f"โœ— Error during testing: {e}") - import traceback - traceback.print_exc() - - -def test_real_world_scenario(): - """Test a real-world scenario with connection reset.""" - - print("\n\nTesting Real-World Scenario...") - - try: - from core.providers.vad.silero import VADProvider - from collections import deque - - # Mock connection - class MockConnection: - def __init__(self): - self.client_audio_buffer = bytearray() - self.client_voice_window = deque(maxlen=5) - self.last_is_voice = False - self.client_have_voice = False - self.last_activity_time = 0.0 - self.client_voice_stop = False - self.vad = None - - def reset_vad_states(self): - self.client_audio_buffer = bytearray() - self.client_have_voice = False - self.client_voice_stop = False - if hasattr(self, 'vad') and self.vad is not None: - self.vad.reset() - - # Create VAD with normal config - config = { - "threshold": "0.4", - "min_silence_duration_ms": "1000", - "start_secs": "0.2", - "stop_secs": "0.8", - "min_volume": "0.3" - } - - vad = VADProvider(config) - conn = MockConnection() - conn.vad = vad - - print("1. Simulating first conversation...") - # Mock Opus packet (normally would be real encoded audio) - mock_opus = b'\xf8\xff\xfe' * 60 - - # Process some "audio" - for i in range(3): - result = vad.is_vad(conn, mock_opus) - print(f" Frame {i+1}: VAD result = {result}") - - if hasattr(vad, 'analyzer'): - print(f" Final state: {vad.analyzer._vad_state.name}") - - print("\n2. Resetting for new conversation...") - conn.reset_vad_states() - - if hasattr(vad, 'analyzer'): - print(f" State after reset: {vad.analyzer._vad_state.name}") - print(f" Clean slate: {vad.analyzer._vad_state == VADState.QUIET}") - - print("\nโœ“ Real-world scenario test completed!") - - except Exception as e: - print(f"โœ— Error: {e}") - import traceback - traceback.print_exc() - - -if __name__ == "__main__": - test_vad_state_transitions() - test_real_world_scenario() \ No newline at end of file diff --git a/main/xiaozhi-server/test_vad_upgrade.py b/main/xiaozhi-server/test_vad_upgrade.py deleted file mode 100644 index 32837fe12..000000000 --- a/main/xiaozhi-server/test_vad_upgrade.py +++ /dev/null @@ -1,130 +0,0 @@ -"""Test script for the upgraded VAD implementation.""" - -import numpy as np -import time -from collections import deque - -# Mock connection class for testing -class MockConnection: - def __init__(self): - self.client_audio_buffer = bytearray() - self.client_voice_window = deque(maxlen=5) - self.last_is_voice = False - self.client_have_voice = False - self.last_activity_time = 0.0 - self.client_voice_stop = False - - -def test_vad_implementation(): - """Test the VAD implementation with sample audio.""" - - print("Testing VAD Implementation...") - - # Test configuration - config = { - "model_dir": "models/snakers4_silero-vad", - "threshold": "0.5", - "threshold_low": "0.2", - "min_silence_duration_ms": "1000", - "frame_window_threshold": 3, - "start_secs": "0.2", - "stop_secs": "0.8", - "min_volume": "0.6" - } - - try: - # Try to import and test the VAD - from core.providers.vad.silero import VADProvider - - print("Creating VAD provider...") - vad = VADProvider(config) - - # Check which implementation was loaded - if hasattr(vad, 'analyzer'): - print("โœ“ ONNX-based VAD loaded successfully!") - print(f" - VAD State: {vad.analyzer._vad_state.name}") - print(f" - Sample Rate: {vad.analyzer.sample_rate}") - print(f" - Params: {vad.analyzer.params}") - else: - print("โœ“ PyTorch-based VAD loaded (fallback)") - - # Create mock connection - conn = MockConnection() - - # Generate test audio (silence) - print("\nTesting with silent audio...") - silent_opus = b'\xf8\xff\xfe' * 60 # Mock silent Opus packet - - # Test VAD with silent audio - result = vad.is_vad(conn, silent_opus) - print(f" - Voice detected: {result}") - print(f" - Connection voice state: {conn.client_have_voice}") - - print("\nVAD test completed successfully!") - - except ImportError as e: - print(f"โœ— Import error: {e}") - print(" Make sure all dependencies are installed") - except Exception as e: - print(f"โœ— Error during testing: {e}") - import traceback - traceback.print_exc() - - -def test_vad_analyzer_directly(): - """Test the VAD analyzer component directly.""" - - print("\n\nTesting VAD Analyzer directly...") - - try: - from core.providers.vad.vad_analyzer import VADAnalyzer, VADParams, VADState - from core.providers.vad.silero_onnx import SileroVADAnalyzer - - # Check if ONNX model exists - model_path = "models/snakers4_silero-vad/src/silero_vad/data/silero_vad.onnx" - import os - - if not os.path.exists(model_path): - print(f"โœ— ONNX model not found at: {model_path}") - return - - print(f"โœ“ ONNX model found at: {model_path}") - - # Create analyzer - params = VADParams( - confidence=0.5, - start_secs=0.2, - stop_secs=0.8, - min_volume=0.6 - ) - - analyzer = SileroVADAnalyzer( - model_path=model_path, - sample_rate=16000, - params=params - ) - - print(f"โœ“ Analyzer created successfully") - print(f" - Initial state: {analyzer._vad_state.name}") - print(f" - Frames required: {analyzer.num_frames_required()}") - - # Generate test audio (512 samples = 1024 bytes for 16kHz) - silent_audio = np.zeros(512, dtype=np.int16).tobytes() - - # Process multiple frames - print("\nProcessing audio frames...") - for i in range(5): - state = analyzer.analyze_audio(silent_audio) - print(f" Frame {i+1}: State = {state.name}") - - print("\nVAD Analyzer test completed!") - - except Exception as e: - print(f"โœ— Error testing analyzer: {e}") - import traceback - traceback.print_exc() - - -if __name__ == "__main__": - test_vad_implementation() - test_vad_analyzer_directly() \ No newline at end of file diff --git a/main/xiaozhi-server/test_voice_format.py b/main/xiaozhi-server/test_voice_format.py deleted file mode 100644 index 61b9c5ed2..000000000 --- a/main/xiaozhi-server/test_voice_format.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python3 -""" -Test script to verify voice format handling -""" - -import sys -import os - -# Add the main directory to Python path -sys.path.append(os.path.join(os.path.dirname(__file__), 'main', 'xiaozhi-server')) - -from core.providers.tts.siliconflow import TTSProvider - -def test_voice_format(): - """Test that voice names are correctly formatted with model prefix""" - - # Test configurations - test_configs = [ - { - "access_token": "test_token", - "model": "FunAudioLLM/CosyVoice2-0.5B", - "voice": "diana", # Should become FunAudioLLM/CosyVoice2-0.5B:diana - }, - { - "access_token": "test_token", - "model": "FunAudioLLM/CosyVoice2-0.5B", - "voice": "FunAudioLLM/CosyVoice2-0.5B:alex", # Should stay as is - }, - { - "access_token": "test_token", - "model": "FunAudioLLM/CosyVoice2-0.5B", - # No voice specified - should default to diana with prefix - } - ] - - for i, config in enumerate(test_configs): - try: - provider = TTSProvider(config, delete_audio_file=True) - print(f"Test {i+1}:") - print(f" Input voice: {config.get('voice', 'None (default)')}") - print(f" Final voice: {provider.voice}") - print(f" Model: {provider.model}") - - # Test available voices - voices = provider.get_available_voices() - print(f" Available voices: {voices}") - print() - - except Exception as e: - print(f"Test {i+1} failed: {e}") - print() - -if __name__ == "__main__": - print("Testing SiliconFlow voice format handling...") - test_voice_format() \ No newline at end of file diff --git a/main/xiaozhi-server/test_weather_final.py b/main/xiaozhi-server/test_weather_final.py deleted file mode 100644 index 444a31834..000000000 --- a/main/xiaozhi-server/test_weather_final.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env python3 -""" -Final test of weather service with actual API key -""" - -import sys -import os -sys.path.append('.') - - -def test_weather_service(): - """Test the weather service with the updated API key function""" - print("๐ŸŒค๏ธ Final Weather Service Test ๐ŸŒค๏ธ\n") - - try: - from plugins_func.functions.get_weather import get_openweather_api_key, get_weather - from plugins_func.register import ActionResponse - - # Test API key function - api_key = get_openweather_api_key() - print(f"๐Ÿ”‘ API Key: {api_key[:8]}...{api_key[-4:]}") - - # Mock connection - class MockConnection: - def __init__(self): - self.config = { - "plugins": { - "get_weather": { - "default_location": "Mumbai" - } - } - } - self.client_ip = "103.21.58.66" - - conn = MockConnection() - - # Test weather function - print("๐Ÿงช Testing weather function...") - result = get_weather(conn, location="Mumbai", lang="en_US") - - if isinstance(result, ActionResponse): - print("โœ… Weather function executed successfully!") - print("\n๐Ÿ“„ Weather Report Preview:") - preview = result.result[:300] + \ - "..." if len(result.result) > 300 else result.result - print(preview) - - # Test with another city - print("\n๐Ÿงช Testing with Delhi...") - result2 = get_weather(conn, location="Delhi", lang="en_US") - if isinstance(result2, ActionResponse): - print("โœ… Delhi weather also working!") - preview2 = result2.result[:200] + \ - "..." if len(result2.result) > 200 else result2.result - print(preview2) - - return True - else: - print(f"โŒ Unexpected result type: {type(result)}") - return False - - except Exception as e: - print(f"โŒ Error: {e}") - import traceback - traceback.print_exc() - return False - - -if __name__ == "__main__": - success = test_weather_service() - - if success: - print("\n๐ŸŽ‰ Weather service is working perfectly!") - print("โœ… Your OpenWeatherMap integration is ready") - print("โœ… Indian cities are supported") - print("โœ… International cities work too") - print("\n๐Ÿš€ You can now:") - print("1. Start the server: python app.py") - print("2. Ask for weather: 'What's the weather in Mumbai?'") - print("3. Try other cities: 'Delhi weather', 'Bangalore forecast'") - else: - print("\nโŒ Weather service test failed") - print("Please check your API key and try again") diff --git a/main/xiaozhi-server/test_weather_service.py b/main/xiaozhi-server/test_weather_service.py deleted file mode 100644 index c55d41016..000000000 --- a/main/xiaozhi-server/test_weather_service.py +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env python3 -""" -Test script for OpenWeatherMap weather service -""" - -import sys -import os -sys.path.append(os.path.dirname(os.path.abspath(__file__))) - - -def test_weather_service(): - """Test the weather service with OpenWeatherMap""" - print("๐ŸŒค๏ธ Testing OpenWeatherMap Weather Service ๐ŸŒค๏ธ\n") - - # Set up environment - # Replace with your actual key - os.environ['WEATHER_API'] = '12dd0eea5789636262549c9ec7f4f7d8' - - from plugins_func.functions.get_weather import get_weather, normalize_indian_city_name - from plugins_func.register import ActionResponse - from config.logger import setup_logging - - logger = setup_logging() - - # Mock connection object - class MockConnection: - def __init__(self): - self.config = { - "plugins": { - "get_weather": { - "api_key": "your_openweathermap_api_key_here", - "default_location": "Mumbai", - "units": "metric", - "lang": "en" - } - } - } - self.client_ip = "103.21.58.66" # Mumbai IP for testing - - mock_conn = MockConnection() - - print("=== Testing Indian City Name Normalization ===") - test_cities = ["bombay", "calcutta", "madras", - "bangalore", "delhi", "mumbai", "chennai"] - for city in test_cities: - normalized = normalize_indian_city_name(city) - print(f" {city} โ†’ {normalized}") - print() - - print("=== Testing Weather Function ===") - - # Test cases - test_cases = [ - {"location": None, "description": "Default location (based on IP)"}, - {"location": "Mumbai", "description": "Mumbai weather"}, - {"location": "Delhi", "description": "Delhi weather"}, - {"location": "Bangalore", "description": "Bangalore weather"}, - {"location": "London", "description": "International city (London)"}, - ] - - for test_case in test_cases: - print(f"๐Ÿ“ Testing: {test_case['description']}") - - try: - result = get_weather( - mock_conn, location=test_case["location"], lang="en_US") - - if isinstance(result, ActionResponse): - print(f"โœ… Success!") - print(f"๐Ÿ“„ Response preview (first 200 chars):") - preview = result.result[:200] + \ - "..." if len(result.result) > 200 else result.result - print(f" {preview}") - else: - print(f"โŒ Unexpected result type: {type(result)}") - - except Exception as e: - print(f"โŒ Error: {e}") - - print("-" * 50) - - print("\n=== API Key Configuration Test ===") - - # Test API key detection - from plugins_func.functions.get_weather import get_openweather_api_key - - api_key = get_openweather_api_key() - if api_key and api_key != "your_openweathermap_api_key_here": - print("โœ… API key is configured") - print(f" Key preview: {api_key[:8]}...{api_key[-4:]}") - else: - print("โŒ API key not configured properly") - print(" Please set your OpenWeatherMap API key in the WEATHER_API environment variable") - print(" Example: export WEATHER_API='your_actual_api_key_here'") - - print("\n=== Integration Test Summary ===") - print("โœ… Indian city name normalization working") - print("โœ… Weather function structure correct") - print("โœ… OpenWeatherMap API integration ready") - print("โœ… Caching system integrated") - print("โœ… Error handling implemented") - - print("\n๐Ÿš€ Next Steps:") - print("1. Replace 'your_openweathermap_api_key_here' with your actual API key") - print("2. Set the WEATHER_API environment variable") - print("3. Test with the real server") - print("4. The weather service will work with Indian cities and international locations!") - - -def test_api_key_setup(): - """Test if API key is properly set up""" - print("\n=== API Key Setup Test ===") - - # Check environment variable - env_key = os.getenv('WEATHER_API') - if env_key and env_key != 'your_openweathermap_api_key_here': - print(f"โœ… Environment variable WEATHER_API is set") - print(f" Key preview: {env_key[:8]}...{env_key[-4:]}") - return True - else: - print("โŒ Environment variable WEATHER_API not set or using placeholder") - print(" Please run: export WEATHER_API='your_actual_api_key_here'") - return False - - -if __name__ == "__main__": - # Test API key setup first - api_configured = test_api_key_setup() - - # Run weather service tests - test_weather_service() - - if not api_configured: - print("\nโš ๏ธ Important: Replace the placeholder API key with your actual OpenWeatherMap API key!") - print(" Get your free API key at: https://openweathermap.org/api")