feat: Enhance audio normalization service to handle invalid analysis values and improve fallback logic
This commit is contained in:
@@ -216,6 +216,18 @@ class SoundNormalizerService:
|
||||
|
||||
logger.debug("Found JSON match: %s", json_match.group())
|
||||
analysis_data = json.loads(json_match.group())
|
||||
|
||||
# Check for invalid values that would cause second pass to fail
|
||||
invalid_values = ["-inf", "inf", "nan"]
|
||||
for key in ["input_i", "input_lra", "input_tp", "input_thresh", "target_offset"]:
|
||||
if str(analysis_data.get(key, "")).lower() in invalid_values:
|
||||
logger.warning(
|
||||
"Invalid analysis value for %s: %s. Falling back to one-pass normalization.",
|
||||
key, analysis_data.get(key)
|
||||
)
|
||||
# Fall back to one-pass normalization
|
||||
await self._normalize_audio_one_pass(input_path, output_path)
|
||||
return
|
||||
|
||||
# Second pass: normalize with measured values
|
||||
logger.debug("Second pass: normalizing %s with measured values", input_path)
|
||||
|
||||
Reference in New Issue
Block a user