"""
简单的导入测试
验证模块结构是否正确
"""

import sys
from pathlib import Path

# 添加模块路径
module_path = Path(__file__).parent
sys.path.insert(0, str(module_path))

print("=" * 60)
print("语音唤醒模块 - 导入测试")
print("=" * 60)

try:
    print("\n1. 测试导入配置类...")
    from config import WakeWordConfig
    print("   ✅ WakeWordConfig 导入成功")

    print("\n2. 测试导入音频采集类...")
    from audio_capture import AudioCapture, AudioListener
    print("   ✅ AudioCapture 导入成功")

    print("\n3. 测试导入检测器类...")
    from detector import WakeWordDetector
    print("   ✅ WakeWordDetector 导入成功")

    print("\n4. 测试导入AEC处理器类...")
    from aec_processor import AECProcessor
    print("   ✅ AECProcessor 导入成功")

    print("\n5. 测试从 __init__ 导入...")
    from wake_word_module import WakeWordDetector, AudioCapture, WakeWordConfig, AECProcessor
    print("   ✅ 从 __init__ 导入成功")

    print("\n6. 测试配置创建...")
    config = WakeWordConfig(
        model_path="models",
        sample_rate=16000,
    )
    print(f"   ✅ 配置创建成功")
    print(f"   - 采样率: {config.sample_rate}Hz")
    print(f"   - 阈值: {config.keywords_threshold}")

    print("\n7. 测试音频采集器创建...")
    audio_capture = AudioCapture(sample_rate=16000, channels=1)
    print(f"   ✅ 音频采集器创建成功")
    print(f"   - 采样率: {audio_capture.sample_rate}Hz")
    print(f"   - 声道数: {audio_capture.channels}")
    print(f"   - AEC启用: {audio_capture.enable_aec}")

    print("\n8. 测试AEC处理器创建...")
    aec_processor = AECProcessor(sample_rate=16000, channels=1)
    print(f"   ✅ AEC处理器创建成功")
    print(f"   - 平台: {aec_processor._platform}")

    print("\n" + "=" * 60)
    print("✅ 所有导入测试通过!")
    print("=" * 60)

    print("\n注意: 完整功能测试需要:")
    print("  1. 安装依赖: pip install -r requirements.txt")
    print("  2. 准备模型文件到 models/ 目录")
    print("  3. 运行: python test.py")
    print("  4. 测试AEC: python test_aec.py")
    print("\nAEC说明:")
    print("  - Windows/Linux: 自动使用系统级AEC")
    print("  - macOS: 需要WebRTC APM库和BlackHole设备")
    print("  - 详见: AEC_GUIDE.md")

except Exception as e:
    print(f"\n❌ 导入测试失败: {e}")
    import traceback
    traceback.print_exc()
    sys.exit(1)