feat(stream): integrate sound normalization into stream processing service
This commit is contained in:
@@ -453,6 +453,9 @@ class StreamProcessingService:
|
||||
|
||||
# Add sound to main playlist
|
||||
cls._add_sound_to_main_playlist(sound)
|
||||
|
||||
# Normalize the sound
|
||||
cls._normalize_sound(sound)
|
||||
|
||||
return sound, None
|
||||
|
||||
@@ -541,6 +544,30 @@ class StreamProcessingService:
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to add sound {sound.id} to main playlist: {e}")
|
||||
|
||||
@classmethod
|
||||
def _normalize_sound(cls, sound: Sound) -> None:
|
||||
"""Normalize a stream sound using the sound normalizer service."""
|
||||
try:
|
||||
from app.services.sound_normalizer_service import SoundNormalizerService
|
||||
|
||||
logger.info(f"Starting normalization of stream sound {sound.id}: {sound.name}")
|
||||
|
||||
# Normalize the sound (overwrite=True since it's a new sound)
|
||||
result = SoundNormalizerService.normalize_sound(
|
||||
sound.id,
|
||||
overwrite=True,
|
||||
two_pass=True
|
||||
)
|
||||
|
||||
if result.get("success"):
|
||||
logger.info(f"Successfully normalized stream sound {sound.id}")
|
||||
else:
|
||||
error_msg = result.get("error", "Unknown normalization error")
|
||||
logger.warning(f"Failed to normalize stream sound {sound.id}: {error_msg}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error normalizing stream sound {sound.id}: {e}")
|
||||
|
||||
@classmethod
|
||||
def _calculate_file_hash(cls, file_path: str) -> str:
|
||||
"""Calculate SHA256 hash of file."""
|
||||
|
||||
Reference in New Issue
Block a user