Skip to content

Commit

Permalink
build: add numpy2 support
Browse files Browse the repository at this point in the history
Identified necessary code changes with the NPY201 ruff rule. Gruut is the only
dependency that doesn't support numpy2 yet.

NB: At build time numpy>=2.0.0 should be required to be able to build wheels
compatible with both numpy1+2:
https://numpy.org/devdocs/dev/depending_on_numpy.html#numpy-2-abi-handling
  • Loading branch information
eginhard committed Jun 16, 2024
1 parent 3a20f47 commit 4bc0e75
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions TTS/vc/models/freevc.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,7 @@ def load_pretrained_speaker_encoder(self):
"""Load pretrained speaker encoder model as mentioned in the paper."""
logger.info("Loading pretrained speaker encoder model ...")
self.enc_spk_ex = SpeakerEncoderEx(
"https://github.com/coqui-ai/TTS/releases/download/v0.13.0_models/speaker_encoder.pt",
device=self.device
"https://github.com/coqui-ai/TTS/releases/download/v0.13.0_models/speaker_encoder.pt", device=self.device
)

def init_multispeaker(self, config: Coqpit):
Expand Down
4 changes: 2 additions & 2 deletions TTS/vocoder/models/wavernn.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(
use_aux_net,
):
super().__init__()
self.total_scale = np.cumproduct(upsample_scales)[-1]
self.total_scale = np.cumprod(upsample_scales)[-1]
self.indent = pad * self.total_scale
self.use_aux_net = use_aux_net
if use_aux_net:
Expand Down Expand Up @@ -239,7 +239,7 @@ class of models has however remained an elusive problem. With a focus on text-to

if self.args.use_upsample_net:
assert (
np.cumproduct(self.args.upsample_factors)[-1] == config.audio.hop_length
np.cumprod(self.args.upsample_factors)[-1] == config.audio.hop_length
), " [!] upsample scales needs to be equal to hop_length"
self.upsample = UpsampleNetwork(
self.args.feat_dims,
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
requires = [
"setuptools",
"cython~=0.29.30",
"numpy>=1.24.3",
"numpy>=2.0.0",
]
build-backend = "setuptools.build_meta"

Expand Down Expand Up @@ -84,7 +84,7 @@ dev = [
"coverage[toml]",
"nose2",
"pre-commit",
"ruff==0.3.0",
"ruff==0.4.9",
"tomli; python_version < '3.11'",
]
# Dependencies for building the documentation
Expand Down Expand Up @@ -169,6 +169,7 @@ lint.extend-select = [
"PLR1711", # useless-return
"PLW",
"W291", # trailing-whitespace
"NPY201", # NumPy 2.0 deprecation
]

lint.ignore = [
Expand Down
2 changes: 1 addition & 1 deletion requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ black==24.2.0
coverage[toml]
nose2
pre-commit
ruff==0.3.0
ruff==0.4.9
tomli; python_version < '3.11'

0 comments on commit 4bc0e75

Please sign in to comment.