Skip to content

Commit

Permalink
sync with applio
Browse files Browse the repository at this point in the history
  • Loading branch information
blaisewf committed Oct 25, 2024
1 parent 5104608 commit 379b2e5
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 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,29 @@ 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 379b2e5

Please sign in to comment.