Skip to content

Commit

Permalink
prevent overflow in numpy.int32 type
Browse files Browse the repository at this point in the history
  • Loading branch information
Patchethium committed Sep 2, 2023
1 parent 6c4fe0a commit b19783d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions voicevox_engine/guided/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def _query2phoneme(query: AudioQuery) -> List[str]:
def _align(wav: np.ndarray, src_sr: int, query: AudioQuery):
if len(wav.shape) == 2:
wav = np.sum(wav, axis=1) / 2
wav = resample(wav, aligner.sr * wav.shape[0] // src_sr)
# convert to int, to avoid overflow in np.int32 type
wav = resample(wav, int(aligner.sr) * int(wav.shape[0]) // src_sr)
ph = _query2phoneme(query)
segments, *_ = aligner(wav, ph, use_sec=False)

Expand Down Expand Up @@ -89,7 +90,6 @@ def extract(wav: np.ndarray, src_sr: int, query: AudioQuery, model_path: str):
# stereo to mono
if len(wav.shape) == 2:
wav = np.sum(wav, axis=1) / 2

segments = _align(wav, src_sr, query)

segments = _guard_long_vowel(segments)
Expand Down

0 comments on commit b19783d

Please sign in to comment.