Skip to content

Commit

Permalink
Merge pull request #827 from AznamirWoW/preprocess_normalize
Browse files Browse the repository at this point in the history
moved audio normalization to pre-splitting
  • Loading branch information
blaisewf authored Oct 18, 2024
2 parents 62fd0f7 + 365a19b commit d80c04f
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions rvc/train/preprocess/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,11 @@ def _normalize_audio(self, audio: np.ndarray):

def process_audio_segment(
self,
audio_segment: np.ndarray,
normalized_audio: np.ndarray,
sid: int,
idx0: int,
idx1: int,
process_effects: bool,
):
normalized_audio = (
self._normalize_audio(audio_segment) if process_effects else audio_segment
)
if normalized_audio is None:
print(f"{sid}-{idx0}-{idx1}-filtered")
return
Expand Down Expand Up @@ -105,6 +101,7 @@ def process_audio(
audio_length = librosa.get_duration(y=audio, sr=self.sr)
if process_effects:
audio = signal.lfilter(self.b_high, self.a_high, audio)
audio = self._normalize_audio(audio)
if noise_reduction:
audio = nr.reduce_noise(
y=audio, sr=self.sr, prop_decrease=reduction_strength
Expand All @@ -121,18 +118,18 @@ def process_audio(
start : start + int(self.per * self.sr)
]
self.process_audio_segment(
tmp_audio, sid, idx0, idx1, process_effects
tmp_audio, sid, idx0, idx1,
)
idx1 += 1
else:
tmp_audio = audio_segment[start:]
self.process_audio_segment(
tmp_audio, sid, idx0, idx1, process_effects
tmp_audio, sid, idx0, idx1,
)
idx1 += 1
break
else:
self.process_audio_segment(audio, sid, idx0, idx1, process_effects)
self.process_audio_segment(audio, sid, idx0, idx1,)
except Exception as error:
print(f"Error processing audio: {error}")
return audio_length
Expand Down

0 comments on commit d80c04f

Please sign in to comment.