feat(stream): integrate sound normalization into stream processing service
This commit is contained in:
@@ -27,8 +27,17 @@ class SoundNormalizerService:
|
||||
".aac",
|
||||
".opus",
|
||||
}
|
||||
SOUNDS_DIR = "sounds/soundboard"
|
||||
NORMALIZED_DIR = "sounds/normalized/soundboard"
|
||||
# Sound directories by type
|
||||
SOUND_DIRS = {
|
||||
"SDB": "sounds/soundboard",
|
||||
"SAY": "sounds/say",
|
||||
"STR": "sounds/stream"
|
||||
}
|
||||
NORMALIZED_DIRS = {
|
||||
"SDB": "sounds/normalized/soundboard",
|
||||
"SAY": "sounds/normalized/say",
|
||||
"STR": "sounds/normalized/stream"
|
||||
}
|
||||
|
||||
LOUDNORM_PARAMS = {
|
||||
"integrated": -16,
|
||||
@@ -62,9 +71,17 @@ class SoundNormalizerService:
|
||||
"error": f"Sound with ID {sound_id} not found",
|
||||
}
|
||||
|
||||
source_path = (
|
||||
Path(SoundNormalizerService.SOUNDS_DIR) / sound.filename
|
||||
)
|
||||
# Get directories based on sound type
|
||||
sound_dir = SoundNormalizerService.SOUND_DIRS.get(sound.type)
|
||||
normalized_dir = SoundNormalizerService.NORMALIZED_DIRS.get(sound.type)
|
||||
|
||||
if not sound_dir or not normalized_dir:
|
||||
return {
|
||||
"success": False,
|
||||
"error": f"Unsupported sound type: {sound.type}",
|
||||
}
|
||||
|
||||
source_path = Path(sound_dir) / sound.filename
|
||||
if not source_path.exists():
|
||||
return {
|
||||
"success": False,
|
||||
@@ -74,10 +91,7 @@ class SoundNormalizerService:
|
||||
# Always output as WAV regardless of input format
|
||||
filename_without_ext = Path(sound.filename).stem
|
||||
normalized_filename = f"{filename_without_ext}.wav"
|
||||
normalized_path = (
|
||||
Path(SoundNormalizerService.NORMALIZED_DIR)
|
||||
/ normalized_filename
|
||||
)
|
||||
normalized_path = Path(normalized_dir) / normalized_filename
|
||||
|
||||
normalized_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user