From a58cb9abb4b049dc65151fb777a77267fa28b6d3 Mon Sep 17 00:00:00 2001 From: ntamotsu <129183927+ntamotsu@users.noreply.github.com> Date: Sun, 8 Dec 2024 14:03:00 +0900 Subject: [PATCH] Change default amplification_threshold to 0.0 (#151) (#153) --- README.md | 2 +- audio_separator/separator/separator.py | 6 +++--- audio_separator/utils/cli.py | 2 +- tests/unit/test_cli.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6bc1e3b..6dbe083 100644 --- a/README.md +++ b/README.md @@ -289,7 +289,7 @@ You can also rename specific stems: - output_dir: (Optional) Directory where the separated files will be saved. If not specified, uses the current directory. - output_format: (Optional) Format to encode output files, any common format (WAV, MP3, FLAC, M4A, etc.). Default: WAV - normalization_threshold: (Optional) The amount by which the amplitude of the output audio will be multiplied. Default: 0.9 -- amplification_threshold: (Optional) The minimum amplitude level at which the waveform will be amplified. If the peak amplitude of the audio is below this threshold, the waveform will be scaled up to meet it. Default: 0.6 +- amplification_threshold: (Optional) The minimum amplitude level at which the waveform will be amplified. If the peak amplitude of the audio is below this threshold, the waveform will be scaled up to meet it. Default: 0.0 - output_single_stem: (Optional) Output only a single stem, such as 'Instrumental' and 'Vocals'. Default: None - invert_using_spec: (Optional) Flag to invert using spectrogram. Default: False - sample_rate: (Optional) Set the sample rate of the output audio. Default: 44100 diff --git a/audio_separator/separator/separator.py b/audio_separator/separator/separator.py index 3e1d9ca..d1f8d40 100644 --- a/audio_separator/separator/separator.py +++ b/audio_separator/separator/separator.py @@ -85,7 +85,7 @@ def __init__( output_format="WAV", output_bitrate=None, normalization_threshold=0.9, - amplification_threshold=0.6, + amplification_threshold=0.0, output_single_stem=None, invert_using_spec=False, sample_rate=44100, @@ -142,8 +142,8 @@ def __init__( raise ValueError("The normalization_threshold must be greater than 0 and less than or equal to 1.") self.amplification_threshold = amplification_threshold - if amplification_threshold <= 0 or amplification_threshold > 1: - raise ValueError("The amplification_threshold must be greater than 0 and less than or equal to 1.") + if amplification_threshold < 0 or amplification_threshold > 1: + raise ValueError("The amplification_threshold must be greater than or equal to 0 and less than or equal to 1.") self.output_single_stem = output_single_stem if output_single_stem is not None: diff --git a/audio_separator/utils/cli.py b/audio_separator/utils/cli.py index 548c965..cca3e98 100755 --- a/audio_separator/utils/cli.py +++ b/audio_separator/utils/cli.py @@ -62,7 +62,7 @@ def main(): common_params = parser.add_argument_group("Common Separation Parameters") common_params.add_argument("--invert_spect", action="store_true", help=invert_spect_help) common_params.add_argument("--normalization", type=float, default=0.9, help=normalization_help) - common_params.add_argument("--amplification", type=float, default=0.6, help=amplification_help) + common_params.add_argument("--amplification", type=float, default=0.0, help=amplification_help) common_params.add_argument("--single_stem", default=None, help=single_stem_help) common_params.add_argument("--sample_rate", type=int, default=44100, help=sample_rate_help) common_params.add_argument("--use_soundfile", action="store_true", help=use_soundfile_help) diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.py index 56b66d6..e763d4e 100644 --- a/tests/unit/test_cli.py +++ b/tests/unit/test_cli.py @@ -17,7 +17,7 @@ def common_expected_args(): "output_format": "FLAC", "output_bitrate": None, "normalization_threshold": 0.9, - "amplification_threshold": 0.6, + "amplification_threshold": 0.0, "output_single_stem": None, "invert_using_spec": False, "sample_rate": 44100,