Spaces:
Sleeping
Sleeping
| try: | |
| import pyloudnorm as pyln | |
| LOUDNESS_AVAILABLE = True | |
| except ImportError: | |
| LOUDNESS_AVAILABLE = False | |
| def compute_loudness(y, sr): | |
| """ | |
| Compute integrated LUFS using pyloudnorm. | |
| Returns None if pyloudnorm is not installed or fails. | |
| """ | |
| if not LOUDNESS_AVAILABLE: | |
| return None | |
| try: | |
| meter = pyln.Meter(sr) | |
| loudness = float(meter.integrated_loudness(y)) | |
| return loudness | |
| except Exception: | |
| return None | |