parent
63002dc36f
commit
1c4e4e7d9c
@ -1,13 +0,0 @@
|
||||
# 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.
|
@ -1,13 +0,0 @@
|
||||
# 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.
|
@ -0,0 +1,89 @@
|
||||
import itertools
|
||||
from unittest import skipIf
|
||||
|
||||
from paddleaudio._internal.module_utils import is_module_available
|
||||
from parameterized import parameterized
|
||||
|
||||
|
||||
def name_func(func, _, params):
|
||||
return f'{func.__name__}_{"_".join(str(arg) for arg in params.args)}'
|
||||
|
||||
|
||||
def dtype2subtype(dtype):
|
||||
return {
|
||||
"float64": "DOUBLE",
|
||||
"float32": "FLOAT",
|
||||
"int32": "PCM_32",
|
||||
"int16": "PCM_16",
|
||||
"uint8": "PCM_U8",
|
||||
"int8": "PCM_S8",
|
||||
}[dtype]
|
||||
|
||||
|
||||
def skipIfFormatNotSupported(fmt):
|
||||
fmts = []
|
||||
if is_module_available("soundfile"):
|
||||
import soundfile
|
||||
|
||||
fmts = soundfile.available_formats()
|
||||
return skipIf(fmt not in fmts, f'"{fmt}" is not supported by soundfile')
|
||||
return skipIf(True, '"soundfile" not available.')
|
||||
|
||||
|
||||
def parameterize(*params):
|
||||
return parameterized.expand(
|
||||
list(itertools.product(*params)), name_func=name_func)
|
||||
|
||||
|
||||
def fetch_wav_subtype(dtype, encoding, bits_per_sample):
|
||||
subtype = {
|
||||
(None, None): dtype2subtype(dtype),
|
||||
(None, 8): "PCM_U8",
|
||||
("PCM_U", None): "PCM_U8",
|
||||
("PCM_U", 8): "PCM_U8",
|
||||
("PCM_S", None): "PCM_32",
|
||||
("PCM_S", 16): "PCM_16",
|
||||
("PCM_S", 32): "PCM_32",
|
||||
("PCM_F", None): "FLOAT",
|
||||
("PCM_F", 32): "FLOAT",
|
||||
("PCM_F", 64): "DOUBLE",
|
||||
("ULAW", None): "ULAW",
|
||||
("ULAW", 8): "ULAW",
|
||||
("ALAW", None): "ALAW",
|
||||
("ALAW", 8): "ALAW",
|
||||
}.get((encoding, bits_per_sample))
|
||||
if subtype:
|
||||
return subtype
|
||||
raise ValueError(f"wav does not support ({encoding}, {bits_per_sample}).")
|
||||
|
||||
def get_encoding(ext, dtype):
|
||||
exts = {
|
||||
"mp3",
|
||||
"flac",
|
||||
"vorbis",
|
||||
}
|
||||
encodings = {
|
||||
"float32": "PCM_F",
|
||||
"int32": "PCM_S",
|
||||
"int16": "PCM_S",
|
||||
"uint8": "PCM_U",
|
||||
}
|
||||
return ext.upper() if ext in exts else encodings[dtype]
|
||||
|
||||
|
||||
def get_bit_depth(dtype):
|
||||
bit_depths = {
|
||||
"float32": 32,
|
||||
"int32": 32,
|
||||
"int16": 16,
|
||||
"uint8": 8,
|
||||
}
|
||||
return bit_depths[dtype]
|
||||
|
||||
def get_bits_per_sample(ext, dtype):
|
||||
bits_per_samples = {
|
||||
"flac": 24,
|
||||
"mp3": 0,
|
||||
"vorbis": 0,
|
||||
}
|
||||
return bits_per_samples.get(ext, get_bit_depth(dtype))
|
@ -0,0 +1 @@
|
||||
../../common_utils
|
@ -0,0 +1,77 @@
|
||||
{"effects": [["allpass", "300", "10"]]}
|
||||
{"effects": [["band", "300", "10"]]}
|
||||
{"effects": [["bandpass", "300", "10"]]}
|
||||
{"effects": [["bandreject", "300", "10"]]}
|
||||
{"effects": [["bass", "-10"]]}
|
||||
{"effects": [["biquad", "0.4", "0.2", "0.9", "0.7", "0.2", "0.6"]]}
|
||||
{"effects": [["chorus", "0.7", "0.9", "55", "0.4", "0.25", "2", "-t"]]}
|
||||
{"effects": [["chorus", "0.6", "0.9", "50", "0.4", "0.25", "2", "-t", "60", "0.32", "0.4", "1.3", "-s"]]}
|
||||
{"effects": [["chorus", "0.5", "0.9", "50", "0.4", "0.25", "2", "-t", "60", "0.32", "0.4", "2.3", "-t", "40", "0.3", "0.3", "1.3", "-s"]]}
|
||||
{"effects": [["channels", "1"]]}
|
||||
{"effects": [["channels", "2"]]}
|
||||
{"effects": [["channels", "3"]]}
|
||||
{"effects": [["compand", "0.3,1", "6:-70,-60,-20", "-5", "-90", "0.2"]]}
|
||||
{"effects": [["compand", ".1,.2", "-inf,-50.1,-inf,-50,-50", "0", "-90", ".1"]]}
|
||||
{"effects": [["compand", ".1,.1", "-45.1,-45,-inf,0,-inf", "45", "-90", ".1"]]}
|
||||
{"effects": [["contrast", "0"]]}
|
||||
{"effects": [["contrast", "25"]]}
|
||||
{"effects": [["contrast", "50"]]}
|
||||
{"effects": [["contrast", "75"]]}
|
||||
{"effects": [["contrast", "100"]]}
|
||||
{"effects": [["dcshift", "1.0"]]}
|
||||
{"effects": [["dcshift", "-1.0"]]}
|
||||
{"effects": [["deemph"]], "input_sample_rate": 44100}
|
||||
{"effects": [["dither", "-s"]]}
|
||||
{"effects": [["dither", "-S"]]}
|
||||
{"effects": [["divide"]]}
|
||||
{"effects": [["downsample", "2"]], "input_sample_rate": 8000, "output_sample_rate": 4000}
|
||||
{"effects": [["earwax"]], "input_sample_rate": 44100}
|
||||
{"effects": [["echo", "0.8", "0.88", "60", "0.4"]]}
|
||||
{"effects": [["echo", "0.8", "0.88", "6", "0.4"]]}
|
||||
{"effects": [["echo", "0.8", "0.9", "1000", "0.3"]]}
|
||||
{"effects": [["echo", "0.8", "0.9", "1000", "0.3", "1800", "0.25"]]}
|
||||
{"effects": [["echos", "0.8", "0.7", "700", "0.25", "700", "0.3"]]}
|
||||
{"effects": [["echos", "0.8", "0.7", "700", "0.25", "900", "0.3"]]}
|
||||
{"effects": [["echos", "0.8", "0.7", "40", "0.25", "63", "0.3"]]}
|
||||
{"effects": [["equalizer", "300", "10", "5"]]}
|
||||
{"effects": [["fade", "q", "3"]]}
|
||||
{"effects": [["fade", "h", "3"]]}
|
||||
{"effects": [["fade", "t", "3"]]}
|
||||
{"effects": [["fade", "l", "3"]]}
|
||||
{"effects": [["fade", "p", "3"]]}
|
||||
{"effects": [["fir", "0.0195", "-0.082", "0.234", "0.891", "-0.145", "0.043"]]}
|
||||
{"effects": [["flanger"]]}
|
||||
{"effects": [["gain", "-l", "-6"]]}
|
||||
{"effects": [["highpass", "-1", "300"]]}
|
||||
{"effects": [["highpass", "-2", "300"]]}
|
||||
{"effects": [["hilbert"]]}
|
||||
{"effects": [["loudness"]]}
|
||||
{"effects": [["lowpass", "-1", "300"]]}
|
||||
{"effects": [["lowpass", "-2", "300"]]}
|
||||
{"effects": [["mcompand", "0.005,0.1 -47,-40,-34,-34,-17,-33", "100", "0.003,0.05 -47,-40,-34,-34,-17,-33", "400", "0.000625,0.0125 -47,-40,-34,-34,-15,-33", "1600", "0.0001,0.025 -47,-40,-34,-34,-31,-31,-0,-30", "6400", "0,0.025 -38,-31,-28,-28,-0,-25"]], "input_sample_rate": 44100}
|
||||
{"effects": [["oops"]]}
|
||||
{"effects": [["overdrive"]]}
|
||||
{"effects": [["pad"]]}
|
||||
{"effects": [["phaser"]]}
|
||||
{"effects": [["remix", "6", "7", "8", "0"]], "num_channels": 8}
|
||||
{"effects": [["remix", "1-3,7", "3"]], "num_channels": 8}
|
||||
{"effects": [["repeat"]]}
|
||||
{"effects": [["reverb"]]}
|
||||
{"effects": [["reverse"]]}
|
||||
{"effects": [["riaa"]], "input_sample_rate": 44100}
|
||||
{"effects": [["silence", "0"]]}
|
||||
{"effects": [["speed", "1.3"]], "input_sample_rate": 4000, "output_sample_rate": 5200}
|
||||
{"effects": [["speed", "0.7"]], "input_sample_rate": 4000, "output_sample_rate": 2800}
|
||||
{"effects": [["stat"]]}
|
||||
{"effects": [["stats"]]}
|
||||
{"effects": [["stretch"]]}
|
||||
{"effects": [["swap"]]}
|
||||
{"effects": [["synth"]]}
|
||||
{"effects": [["tempo", "0.9"]]}
|
||||
{"effects": [["tempo", "1.1"]]}
|
||||
{"effects": [["treble", "3"]]}
|
||||
{"effects": [["tremolo", "300", "40"]]}
|
||||
{"effects": [["tremolo", "300", "50"]]}
|
||||
{"effects": [["trim", "0", "0.1"]]}
|
||||
{"effects": [["upsample", "2"]], "input_sample_rate": 8000, "output_sample_rate": 16000}
|
||||
{"effects": [["vol", "3"]]}
|
@ -1,12 +1,19 @@
|
||||
from .case_utils import name_func
|
||||
from .case_utils import TempDirMixin
|
||||
from .parameterized_utils import nested_params
|
||||
from .wav_utils import get_wav_data
|
||||
from .wav_utils import load_wav
|
||||
from .wav_utils import normalize_wav
|
||||
from .wav_utils import save_wav
|
||||
from .wav_utils import get_wav_data, load_wav, save_wav, normalize_wav
|
||||
from .parameterized_utils import nested_params
|
||||
from .data_utils import get_sinusoid, load_params, load_effects_params
|
||||
from .case_utils import (
|
||||
TempDirMixin,
|
||||
name_func
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"get_wav_data", "load_wav", "save_wav", "normalize_wav", "get_sinusoid",
|
||||
"name_func", "nested_params", "TempDirMixin"
|
||||
"get_wav_data",
|
||||
"load_wav",
|
||||
"save_wav",
|
||||
"normalize_wav",
|
||||
"load_params",
|
||||
"nested_params",
|
||||
"get_sinusoid",
|
||||
"name_func",
|
||||
"load_effects_params"
|
||||
]
|
||||
|
Loading…
Reference in new issue