From 54f06041d48d32ea6bc81a461ec6ee645b993897 Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Fri, 25 Feb 2022 07:29:26 +0000 Subject: [PATCH] add tests, metric dir and format, test=doc --- paddleaudio/CHANGELOG.md | 2 +- .../paddleaudio/backends/soundfile_backend.py | 13 +++++++++++++ .../paddleaudio/backends/sox_backend.py | 13 +++++++++++++ paddleaudio/paddleaudio/features/__init__.py | 5 ++--- .../paddleaudio/functional/__init__.py | 13 +++++++++++++ .../paddleaudio/functional/functional.py | 5 ++--- paddleaudio/paddleaudio/functional/window.py | 2 +- paddleaudio/paddleaudio/io/__init__.py | 19 ++++++++++++++++--- paddleaudio/paddleaudio/kaldi/__init__.py | 13 +++++++++++++ paddleaudio/paddleaudio/metric/__init__.py | 13 +++++++++++++ .../paddleaudio/sox_effects/__init__.py | 13 +++++++++++++ paddleaudio/paddleaudio/utils/__init__.py | 17 ++++++----------- paddleaudio/paddleaudio/utils/download.py | 1 + paddleaudio/paddleaudio/utils/env.py | 5 +++-- paddleaudio/paddleaudio/utils/time.py | 1 + paddleaudio/tests/.gitkeep | 0 16 files changed, 111 insertions(+), 24 deletions(-) create mode 100644 paddleaudio/paddleaudio/metric/__init__.py create mode 100644 paddleaudio/tests/.gitkeep diff --git a/paddleaudio/CHANGELOG.md b/paddleaudio/CHANGELOG.md index e68895674..52d44dd39 100644 --- a/paddleaudio/CHANGELOG.md +++ b/paddleaudio/CHANGELOG.md @@ -1,4 +1,4 @@ # Changelog Date: 2022-2-25, Author: Hui Zhang. - - Refactor architecture. \ No newline at end of file + - Refactor architecture. diff --git a/paddleaudio/paddleaudio/backends/soundfile_backend.py b/paddleaudio/paddleaudio/backends/soundfile_backend.py index e69de29bb..97043fd7b 100644 --- a/paddleaudio/paddleaudio/backends/soundfile_backend.py +++ b/paddleaudio/paddleaudio/backends/soundfile_backend.py @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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/paddleaudio/paddleaudio/backends/sox_backend.py b/paddleaudio/paddleaudio/backends/sox_backend.py index e69de29bb..97043fd7b 100644 --- a/paddleaudio/paddleaudio/backends/sox_backend.py +++ b/paddleaudio/paddleaudio/backends/sox_backend.py @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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/paddleaudio/paddleaudio/features/__init__.py b/paddleaudio/paddleaudio/features/__init__.py index 1688cc5c2..469b4c9ba 100644 --- a/paddleaudio/paddleaudio/features/__init__.py +++ b/paddleaudio/paddleaudio/features/__init__.py @@ -11,7 +11,6 @@ # 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. - -from .librosa import Spectrogram +from .librosa import LogMelSpectrogram from .librosa import MelSpectrogram -from .librosa import LogMelSpectrogram \ No newline at end of file +from .librosa import Spectrogram diff --git a/paddleaudio/paddleaudio/functional/__init__.py b/paddleaudio/paddleaudio/functional/__init__.py index e69de29bb..97043fd7b 100644 --- a/paddleaudio/paddleaudio/functional/__init__.py +++ b/paddleaudio/paddleaudio/functional/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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/paddleaudio/paddleaudio/functional/functional.py b/paddleaudio/paddleaudio/functional/functional.py index ce49cdc43..167795c37 100644 --- a/paddleaudio/paddleaudio/functional/functional.py +++ b/paddleaudio/paddleaudio/functional/functional.py @@ -23,9 +23,8 @@ from numpy import ndarray as array from numpy.lib.stride_tricks import as_strided from scipy import signal -from ..utils import ParameterError from ..backends import depth_convert - +from ..utils import ParameterError __all__ = [ # dsp @@ -726,4 +725,4 @@ def random_crop2d(s: array, crop_len: int, tempo_axis: int=0) -> array: sli = [slice(None) for i in range(s.ndim)] sli[tempo_axis] = slice(idx, idx + crop_len) out = s[tuple(sli)] - return out \ No newline at end of file + return out diff --git a/paddleaudio/paddleaudio/functional/window.py b/paddleaudio/paddleaudio/functional/window.py index e34862b4c..f321b38ef 100644 --- a/paddleaudio/paddleaudio/functional/window.py +++ b/paddleaudio/paddleaudio/functional/window.py @@ -20,7 +20,7 @@ from paddle import Tensor __all__ = [ 'get_window', - + # windows 'taylor', 'hamming', diff --git a/paddleaudio/paddleaudio/io/__init__.py b/paddleaudio/paddleaudio/io/__init__.py index 3a9a01e85..cc2538f7f 100644 --- a/paddleaudio/paddleaudio/io/__init__.py +++ b/paddleaudio/paddleaudio/io/__init__.py @@ -1,6 +1,19 @@ -from .audio import save_wav +# Copyright (c) 2022 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. +from .audio import depth_convert from .audio import load from .audio import normalize -from .audio import to_mono from .audio import resample -from .audio import depth_convert \ No newline at end of file +from .audio import save_wav +from .audio import to_mono diff --git a/paddleaudio/paddleaudio/kaldi/__init__.py b/paddleaudio/paddleaudio/kaldi/__init__.py index e69de29bb..97043fd7b 100644 --- a/paddleaudio/paddleaudio/kaldi/__init__.py +++ b/paddleaudio/paddleaudio/kaldi/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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/paddleaudio/paddleaudio/metric/__init__.py b/paddleaudio/paddleaudio/metric/__init__.py new file mode 100644 index 000000000..97043fd7b --- /dev/null +++ b/paddleaudio/paddleaudio/metric/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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/paddleaudio/paddleaudio/sox_effects/__init__.py b/paddleaudio/paddleaudio/sox_effects/__init__.py index e69de29bb..97043fd7b 100644 --- a/paddleaudio/paddleaudio/sox_effects/__init__.py +++ b/paddleaudio/paddleaudio/sox_effects/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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/paddleaudio/paddleaudio/utils/__init__.py b/paddleaudio/paddleaudio/utils/__init__.py index 5fe0980b5..afb9cedd8 100644 --- a/paddleaudio/paddleaudio/utils/__init__.py +++ b/paddleaudio/paddleaudio/utils/__init__.py @@ -11,20 +11,15 @@ # 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. - -from .env import USER_HOME -from .env import PPAUDIO_HOME -from .env import MODEL_HOME -from .env import DATA_HOME - from .download import decompress from .download import download_and_decompress from .download import load_state_dict_from_url - +from .env import DATA_HOME +from .env import MODEL_HOME +from .env import PPAUDIO_HOME +from .env import USER_HOME from .error import ParameterError - -from .log import logger from .log import Logger - -from .time import Timer +from .log import logger from .time import seconds_to_hms +from .time import Timer diff --git a/paddleaudio/paddleaudio/utils/download.py b/paddleaudio/paddleaudio/utils/download.py index fd4785cd7..4658352f9 100644 --- a/paddleaudio/paddleaudio/utils/download.py +++ b/paddleaudio/paddleaudio/utils/download.py @@ -28,6 +28,7 @@ __all__ = [ 'load_state_dict_from_url', ] + def decompress(file: str): """ Extracts all files from a compressed file. diff --git a/paddleaudio/paddleaudio/utils/env.py b/paddleaudio/paddleaudio/utils/env.py index e202c3803..a2d14b89e 100644 --- a/paddleaudio/paddleaudio/utils/env.py +++ b/paddleaudio/paddleaudio/utils/env.py @@ -23,10 +23,11 @@ import os __all__ = [ 'USER_HOME', 'PPAUDIO_HOME', -'MODEL_HOME' , -'DATA_HOME' , + 'MODEL_HOME', + 'DATA_HOME', ] + def _get_user_home(): return os.path.expanduser('~') diff --git a/paddleaudio/paddleaudio/utils/time.py b/paddleaudio/paddleaudio/utils/time.py index 23af62fc7..105208f91 100644 --- a/paddleaudio/paddleaudio/utils/time.py +++ b/paddleaudio/paddleaudio/utils/time.py @@ -19,6 +19,7 @@ __all__ = [ 'seconds_to_hms', ] + class Timer(object): '''Calculate runing speed and estimated time of arrival(ETA)''' diff --git a/paddleaudio/tests/.gitkeep b/paddleaudio/tests/.gitkeep new file mode 100644 index 000000000..e69de29bb