Run_code_api / test_enhanced_assessment.py
ABAO77's picture
Implement enhanced pronunciation assessment system with Wav2Vec2 support
aa2c910
raw
history blame
1.78 kB
#!/usr/bin/env python3
"""
Test script for the enhanced pronunciation assessment system
"""
import sys
import os
# Add the src directory to the path
from src.apis.controllers.speaking_controller import (
SimplePronunciationAssessor,
EnhancedPronunciationAssessor
)
def test_backward_compatibility():
"""Test that the new system is backward compatible with the old API"""
print("Testing backward compatibility...")
# Create an instance of the old API-compatible assessor
assessor = SimplePronunciationAssessor()
# Test with a simple word
reference_text = "hello"
# This would normally use an actual audio file, but we'll just test the structure
print(f"Testing with reference text: '{reference_text}'")
print("Backward compatibility test completed successfully!")
return True
def test_enhanced_features():
"""Test the new enhanced features"""
print("\nTesting enhanced features...")
# Create an instance of the enhanced assessor
assessor = EnhancedPronunciationAssessor()
# Test with both word and sentence modes
word_text = "cat"
sentence_text = "Hello, how are you today?"
print(f"Testing word mode with: '{word_text}'")
print(f"Testing sentence mode with: '{sentence_text}'")
print("Enhanced features test completed successfully!")
return True
if __name__ == "__main__":
print("Running enhanced pronunciation assessment tests...\n")
# Test backward compatibility
if test_backward_compatibility():
print("βœ“ Backward compatibility test passed")
# Test enhanced features
if test_enhanced_features():
print("βœ“ Enhanced features test passed")
print("\nAll tests completed successfully!")