From 4bc0e75a08933862e00892566c6e3fd6c3b528b7 Mon Sep 17 00:00:00 2001 From: Enno Hermann Date: Sun, 16 Jun 2024 21:58:34 +0200 Subject: [PATCH] build: add numpy2 support 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 --- TTS/vc/models/freevc.py | 3 +-- TTS/vocoder/models/wavernn.py | 4 ++-- pyproject.toml | 5 +++-- requirements.dev.txt | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/TTS/vc/models/freevc.py b/TTS/vc/models/freevc.py index 262fb7504f..ec7cc0e0a6 100644 --- a/TTS/vc/models/freevc.py +++ b/TTS/vc/models/freevc.py @@ -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): diff --git a/TTS/vocoder/models/wavernn.py b/TTS/vocoder/models/wavernn.py index 62f6ee2d2d..901afdff11 100644 --- a/TTS/vocoder/models/wavernn.py +++ b/TTS/vocoder/models/wavernn.py @@ -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: @@ -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, diff --git a/pyproject.toml b/pyproject.toml index ff2ff32dd4..dd4ebaed6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = [ "setuptools", "cython~=0.29.30", - "numpy>=1.24.3", + "numpy>=2.0.0", ] build-backend = "setuptools.build_meta" @@ -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 @@ -169,6 +169,7 @@ lint.extend-select = [ "PLR1711", # useless-return "PLW", "W291", # trailing-whitespace + "NPY201", # NumPy 2.0 deprecation ] lint.ignore = [ diff --git a/requirements.dev.txt b/requirements.dev.txt index 0095dae3c2..1e4a7beff7 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -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'