Spaces:
Running
Running
File size: 1,722 Bytes
98fb113 |
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 |
# performance_config.py
"""
Performance configuration for optimizing SynchroLyrics on resource-constrained environments.
"""
import os
# Performance mode: "normal" | "low_resource" | "ultra_low"
PERFORMANCE_MODE = os.getenv("PERFORMANCE_MODE", "low_resource")
def get_performance_config():
"""Returns performance configuration based on the current mode."""
if PERFORMANCE_MODE == "ultra_low":
return {
"mode": "ultra_low",
"asr_threads": 1,
"summary_threshold": 10000, # Very high threshold
"max_connections": 1,
"chunk_size": 1600, # Very small chunks
"enable_summarizer": False, # Disable completely
"pcm_queue_size": 25,
"text_queue_size": 50,
"llm_context_size": 1024,
"llm_threads": 1,
}
elif PERFORMANCE_MODE == "low_resource":
return {
"mode": "low_resource",
"asr_threads": 1,
"summary_threshold": 5000,
"max_connections": 1,
"chunk_size": 3200,
"enable_summarizer": True,
"pcm_queue_size": 50,
"text_queue_size": 100,
"llm_context_size": 2048,
"llm_threads": 1,
}
else: # normal mode
return {
"mode": "normal",
"asr_threads": 2,
"summary_threshold": 2000,
"max_connections": 2,
"chunk_size": 6400,
"enable_summarizer": True,
"pcm_queue_size": 100,
"text_queue_size": 200,
"llm_context_size": 4096,
"llm_threads": 2,
}
# Get current config
PERF_CONFIG = get_performance_config() |