File size: 2,195 Bytes
9e0d500
 
 
 
 
 
 
 
 
003e10f
 
9e0d500
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Quick API Test Script
Test the FastAPI server locally or on HF
"""

import requests
import sys

# Change this to your HF Space URL or local
#API_URL = "akpande2/Aurator_Coaching"  # For local testing
API_URL = "https://akpande2-aurator-coaching.hf.space"  # For HF testing

def test_health():
    """Test health endpoint"""
    print("Testing /api/health...")
    response = requests.get(f"{API_URL}/api/health")
    print(f"Status: {response.status_code}")
    print(f"Response: {response.json()}\n")
    return response.status_code == 200

def test_analyze(audio_file_path):
    """Test analyze endpoint"""
    print(f"Testing /api/analyze with {audio_file_path}...")
    
    with open(audio_file_path, 'rb') as f:
        files = {'audio_file': f}
        data = {'avatar_gender': 'male'}
        
        response = requests.post(
            f"{API_URL}/api/analyze",
            files=files,
            data=data,
            timeout=60
        )
    
    print(f"Status: {response.status_code}")
    
    if response.status_code == 200:
        result = response.json()
        print(f"Success: {result['success']}")
        print(f"Overall Score: {result['data']['overall_score']}")
        print(f"Processing Time: {result['processing_time_ms']}ms")
        print(f"Tips Count: {len(result['data']['coaching']['tips'])}")
        print(f"Tips Audio: {result['data']['coaching']['tips_audio_url']}")
        print(f"Improved Audio: {result['data']['coaching']['improved_audio_url']}")
    else:
        print(f"Error: {response.text}")
    
    return response.status_code == 200

if __name__ == "__main__":
    print("="*60)
    print("API TEST SCRIPT")
    print("="*60 + "\n")
    
    # Test health
    if not test_health():
        print("❌ Health check failed!")
        sys.exit(1)
    
    print("✅ Health check passed!\n")
    
    # Test analyze (provide your audio file)
    if len(sys.argv) > 1:
        audio_file = sys.argv[1]
        if test_analyze(audio_file):
            print("\n✅ Analysis test passed!")
        else:
            print("\n❌ Analysis test failed!")
    else:
        print("ℹ️  To test analysis: python test_api.py your_audio.wav")