From af98dad33e6c95aad13349b26eebbc71524a45e2 Mon Sep 17 00:00:00 2001 From: chenfeiyu Date: Tue, 10 Mar 2020 08:17:56 +0000 Subject: [PATCH] fix for compatability of python2 and lower versions of numpy --- examples/clarinet/synthesis.py | 1 + examples/clarinet/train.py | 1 + examples/clarinet/utils.py | 1 + examples/deepvoice3/data.py | 14 ++++++++++---- examples/deepvoice3/synthesis.py | 1 + examples/deepvoice3/train.py | 1 + examples/deepvoice3/utils.py | 1 + examples/wavenet/data.py | 1 + examples/wavenet/synthesis.py | 1 + examples/wavenet/train.py | 1 + examples/wavenet/utils.py | 1 + parakeet/models/clarinet/net.py | 1 + parakeet/models/clarinet/parallel_wavenet.py | 1 + parakeet/models/clarinet/utils.py | 2 ++ parakeet/models/deepvoice3/attention.py | 1 + parakeet/models/deepvoice3/conv1dglu.py | 1 + parakeet/models/deepvoice3/converter.py | 1 + parakeet/models/deepvoice3/decoder.py | 1 + parakeet/models/deepvoice3/encoder.py | 1 + parakeet/models/deepvoice3/loss.py | 1 + parakeet/models/deepvoice3/model.py | 1 + parakeet/models/deepvoice3/position_embedding.py | 1 + parakeet/models/wavenet/net.py | 1 + parakeet/models/wavenet/wavenet.py | 1 + parakeet/utils/__init__.py | 13 +++++++++++++ parakeet/utils/layer_tools.py | 1 - 26 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 parakeet/utils/__init__.py diff --git a/examples/clarinet/synthesis.py b/examples/clarinet/synthesis.py index e227237..db12035 100644 --- a/examples/clarinet/synthesis.py +++ b/examples/clarinet/synthesis.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import os import sys import argparse diff --git a/examples/clarinet/train.py b/examples/clarinet/train.py index 1ceb05c..c6039b3 100644 --- a/examples/clarinet/train.py +++ b/examples/clarinet/train.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import os import sys import argparse diff --git a/examples/clarinet/utils.py b/examples/clarinet/utils.py index 8e2f39b..2c3e184 100644 --- a/examples/clarinet/utils.py +++ b/examples/clarinet/utils.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import os import soundfile as sf from tensorboardX import SummaryWriter diff --git a/examples/deepvoice3/data.py b/examples/deepvoice3/data.py index 68f54cd..0d0aaeb 100644 --- a/examples/deepvoice3/data.py +++ b/examples/deepvoice3/data.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import os import csv from pathlib import Path @@ -19,6 +20,7 @@ import numpy as np import pandas as pd import librosa from scipy import signal, io +import six from parakeet.data import DatasetMixin, TransformDataset, FilterDataset from parakeet.g2p.en import text_to_sequence, sequence_to_text @@ -32,6 +34,7 @@ class LJSpeechMetaData(DatasetMixin): self._table = pd.read_csv( csv_path, sep="|", + encoding="utf-8", header=None, quoting=csv.QUOTE_NONE, names=["fname", "raw_text", "normalized_text"]) @@ -122,7 +125,6 @@ class Transform(object): # num_frames n_frames = S_mel_norm.shape[-1] # CAUTION: original number of frames - return (mix_grapheme_phonemes, text_length, speaker_id, S_norm, S_mel_norm, n_frames) @@ -161,17 +163,21 @@ class DataCollector(object): S_mel_norm, num_frames) = example text_sequences.append( np.pad(mix_grapheme_phonemes, (0, max_text_length - text_length - ))) + ), + mode="constant")) lin_specs.append( np.pad(S_norm, ((0, 0), (self._pad_begin, max_frames - - self._pad_begin - num_frames)))) + self._pad_begin - num_frames)), + mode="constant")) mel_specs.append( np.pad(S_mel_norm, ((0, 0), (self._pad_begin, max_frames - - self._pad_begin - num_frames)))) + self._pad_begin - num_frames)), + mode="constant")) done_flags.append( np.pad(np.zeros((int(np.ceil(num_frames // self._factor)), )), (0, max_decoder_length - int( np.ceil(num_frames // self._factor))), + mode="constant", constant_values=1)) text_sequences = np.array(text_sequences).astype(np.int64) lin_specs = np.transpose(np.array(lin_specs), diff --git a/examples/deepvoice3/synthesis.py b/examples/deepvoice3/synthesis.py index 5162e07..6d79d46 100644 --- a/examples/deepvoice3/synthesis.py +++ b/examples/deepvoice3/synthesis.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import os import argparse import ruamel.yaml diff --git a/examples/deepvoice3/train.py b/examples/deepvoice3/train.py index ad42822..11f8407 100644 --- a/examples/deepvoice3/train.py +++ b/examples/deepvoice3/train.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import os import argparse import ruamel.yaml diff --git a/examples/deepvoice3/utils.py b/examples/deepvoice3/utils.py index 1996d7d..42b8db8 100644 --- a/examples/deepvoice3/utils.py +++ b/examples/deepvoice3/utils.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import os import numpy as np from matplotlib import cm diff --git a/examples/wavenet/data.py b/examples/wavenet/data.py index 8d5f6e7..24285ff 100644 --- a/examples/wavenet/data.py +++ b/examples/wavenet/data.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import csv import numpy as np import librosa diff --git a/examples/wavenet/synthesis.py b/examples/wavenet/synthesis.py index 749ecba..9b5487b 100644 --- a/examples/wavenet/synthesis.py +++ b/examples/wavenet/synthesis.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import os import ruamel.yaml import argparse diff --git a/examples/wavenet/train.py b/examples/wavenet/train.py index 174a1bf..df24b10 100644 --- a/examples/wavenet/train.py +++ b/examples/wavenet/train.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import os import ruamel.yaml import argparse diff --git a/examples/wavenet/utils.py b/examples/wavenet/utils.py index 86c8ebf..bae186f 100644 --- a/examples/wavenet/utils.py +++ b/examples/wavenet/utils.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import os import numpy as np import soundfile as sf diff --git a/parakeet/models/clarinet/net.py b/parakeet/models/clarinet/net.py index b25e8e9..1af0493 100644 --- a/parakeet/models/clarinet/net.py +++ b/parakeet/models/clarinet/net.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import itertools import numpy as np from scipy import signal diff --git a/parakeet/models/clarinet/parallel_wavenet.py b/parakeet/models/clarinet/parallel_wavenet.py index 9f7155c..9be958e 100644 --- a/parakeet/models/clarinet/parallel_wavenet.py +++ b/parakeet/models/clarinet/parallel_wavenet.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import math import time import itertools diff --git a/parakeet/models/clarinet/utils.py b/parakeet/models/clarinet/utils.py index c2d3252..d5c2b44 100644 --- a/parakeet/models/clarinet/utils.py +++ b/parakeet/models/clarinet/utils.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division + from paddle import fluid from paddle.fluid.core import ops diff --git a/parakeet/models/deepvoice3/attention.py b/parakeet/models/deepvoice3/attention.py index 2512014..c8dae0e 100644 --- a/parakeet/models/deepvoice3/attention.py +++ b/parakeet/models/deepvoice3/attention.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import numpy as np from collections import namedtuple from paddle import fluid diff --git a/parakeet/models/deepvoice3/conv1dglu.py b/parakeet/models/deepvoice3/conv1dglu.py index 41ae2e4..1af5f4b 100644 --- a/parakeet/models/deepvoice3/conv1dglu.py +++ b/parakeet/models/deepvoice3/conv1dglu.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import numpy as np from paddle import fluid diff --git a/parakeet/models/deepvoice3/converter.py b/parakeet/models/deepvoice3/converter.py index 10b94ca..3c7d058 100644 --- a/parakeet/models/deepvoice3/converter.py +++ b/parakeet/models/deepvoice3/converter.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import numpy as np from itertools import chain diff --git a/parakeet/models/deepvoice3/decoder.py b/parakeet/models/deepvoice3/decoder.py index dcf841d..e525eec 100644 --- a/parakeet/models/deepvoice3/decoder.py +++ b/parakeet/models/deepvoice3/decoder.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import numpy as np import paddle.fluid.layers as F import paddle.fluid.initializer as I diff --git a/parakeet/models/deepvoice3/encoder.py b/parakeet/models/deepvoice3/encoder.py index 3d0b760..fea847f 100644 --- a/parakeet/models/deepvoice3/encoder.py +++ b/parakeet/models/deepvoice3/encoder.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import numpy as np from collections import namedtuple diff --git a/parakeet/models/deepvoice3/loss.py b/parakeet/models/deepvoice3/loss.py index f5e0988..abf6d73 100644 --- a/parakeet/models/deepvoice3/loss.py +++ b/parakeet/models/deepvoice3/loss.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import numpy as np from numba import jit diff --git a/parakeet/models/deepvoice3/model.py b/parakeet/models/deepvoice3/model.py index aaae0a3..5229680 100644 --- a/parakeet/models/deepvoice3/model.py +++ b/parakeet/models/deepvoice3/model.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import numpy as np import paddle.fluid.layers as F diff --git a/parakeet/models/deepvoice3/position_embedding.py b/parakeet/models/deepvoice3/position_embedding.py index 7ae8018..032feff 100644 --- a/parakeet/models/deepvoice3/position_embedding.py +++ b/parakeet/models/deepvoice3/position_embedding.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import numpy as np from paddle import fluid import paddle.fluid.layers as F diff --git a/parakeet/models/wavenet/net.py b/parakeet/models/wavenet/net.py index e6262fe..52762e3 100644 --- a/parakeet/models/wavenet/net.py +++ b/parakeet/models/wavenet/net.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import itertools import numpy as np from scipy import signal diff --git a/parakeet/models/wavenet/wavenet.py b/parakeet/models/wavenet/wavenet.py index 75dc03c..b4c0d49 100644 --- a/parakeet/models/wavenet/wavenet.py +++ b/parakeet/models/wavenet/wavenet.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import division import math import time import itertools diff --git a/parakeet/utils/__init__.py b/parakeet/utils/__init__.py new file mode 100644 index 0000000..abf198b --- /dev/null +++ b/parakeet/utils/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/parakeet/utils/layer_tools.py b/parakeet/utils/layer_tools.py index 863c78c..8ff0631 100644 --- a/parakeet/utils/layer_tools.py +++ b/parakeet/utils/layer_tools.py @@ -13,7 +13,6 @@ # limitations under the License. import numpy as np -from torch import nn import paddle.fluid.dygraph as dg