Spaces:
Running
on
Zero
Running
on
Zero
File size: 4,304 Bytes
a602628 |
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 |
"""
Test generation script for ACE-Step Custom Edition
"""
import sys
from pathlib import Path
import logging
# Add src to path
sys.path.insert(0, str(Path(__file__).parent.parent))
from src import ACEStepEngine, load_config, setup_logging
logger = setup_logging()
def test_basic_generation():
"""Test basic music generation."""
logger.info("\n" + "="*60)
logger.info("Testing Basic Music Generation")
logger.info("="*60)
try:
# Load config
config = load_config()
# Initialize engine
logger.info("Initializing ACE-Step engine...")
engine = ACEStepEngine(config)
# Test generation
logger.info("\nGenerating test audio...")
audio_path = engine.generate(
prompt="A cheerful pop song with piano and drums",
lyrics=None,
duration=10, # Short test
temperature=0.7,
seed=42
)
logger.info(f"\nβ
Generation successful!")
logger.info(f"Output: {audio_path}")
return True
except Exception as e:
logger.error(f"\nβ Generation failed: {e}")
import traceback
traceback.print_exc()
return False
def test_timeline_workflow():
"""Test timeline-based generation."""
logger.info("\n" + "="*60)
logger.info("Testing Timeline Workflow")
logger.info("="*60)
try:
from src import TimelineManager
config = load_config()
timeline = TimelineManager(config)
logger.info("Creating timeline...")
timeline_id = timeline.create_timeline()
logger.info(f"Timeline ID: {timeline_id}")
logger.info("\nβ
Timeline system operational!")
return True
except Exception as e:
logger.error(f"\nβ Timeline test failed: {e}")
return False
def test_audio_processing():
"""Test audio processing utilities."""
logger.info("\n" + "="*60)
logger.info("Testing Audio Processing")
logger.info("="*60)
try:
from src import AudioProcessor
import numpy as np
config = load_config()
processor = AudioProcessor(config)
# Create test audio
test_audio = np.random.randn(2, 44100) * 0.1 # 1 second stereo
# Test normalization
normalized = processor.normalize_audio(test_audio)
logger.info("β Normalization OK")
# Test crossfade
crossfaded = processor.crossfade(test_audio, test_audio, fade_duration=0.5)
logger.info("β Crossfade OK")
logger.info("\nβ
Audio processing operational!")
return True
except Exception as e:
logger.error(f"\nβ Audio processing test failed: {e}")
return False
def main():
"""Run all tests."""
logger.info("""
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ACE-Step Custom Edition - Test Suite β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
""")
results = {
"Audio Processing": test_audio_processing(),
"Timeline Workflow": test_timeline_workflow(),
# "Basic Generation": test_basic_generation(), # Requires model download
}
# Summary
logger.info("\n" + "="*60)
logger.info("Test Summary")
logger.info("="*60)
all_passed = True
for test_name, passed in results.items():
status = "β
PASS" if passed else "β FAIL"
logger.info(f"{status} - {test_name}")
if not passed:
all_passed = False
logger.info("="*60)
if all_passed:
logger.info("\nβ
All tests passed!")
logger.info("\nNote: Full generation test requires model download.")
logger.info("Run: python scripts/download_model.py")
else:
logger.error("\nβ Some tests failed. Check logs above.")
sys.exit(1)
if __name__ == "__main__":
main()
|