Amphion icon indicating copy to clipboard operation
Amphion copied to clipboard

[BUG]: Parameter "--fs" does work properly

Open arsity opened this issue 1 year ago • 0 comments

Describe the bug

The behavior of parameter --fs does work as described in Evaluation README. The README states that it is optional, but if I do not fill in it, it gives out error. Also, no matter I fill in it will int type value (aka 24000) or string type value (aka '24000'), it gives out error.

How To Reproduce

Config/File changes: No changes.

BUG 1: --fs is not actually optional. Run

$ bash egs/metrics/run.sh --reference_folder compare/ref_dir --generated_folder compare/gen_dir --dump_folder compare/dump_dir --metrics "fpc"

Get error

usage: calc_metrics.py [-h] [--ref_dir REF_DIR] [--deg_dir DEG_DIR] [--dump_dir DUMP_DIR]
                       [--metrics METRICS [METRICS ...]] [--fs FS]
calc_metrics.py: error: argument --fs: expected one argument

BUG 2: We fill in the --fs, no matter we fill 24000 (int type) or "24000" (string type), it still does not work properly. If we use "24000"

$ bash egs/metrics/run.sh --reference_folder compare/ref_dir --generated_folder compare/gen_dir --dump_folder compare/dump_dir --metrics "fpc" --fs "24000"

Get error

  0%|                                                                     | 0/3 [00:00<?, ?it/s]
  0%|                                                                     | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/mnt/c/users/lukec/pycharmprojects/Amphion/bins/calc_metrics.py", line 155, in <module>
    calc_metric(args.ref_dir, args.deg_dir, args.dump_dir, args.metrics, args.fs)
  File "/mnt/c/users/lukec/pycharmprojects/Amphion/bins/calc_metrics.py", line 110, in calc_metric
    score = METRIC_FUNC[metric](
  File "/mnt/c/users/lukec/pycharmprojects/Amphion/evaluation/metrics/f0/f0_pearson_coefficients.py", line 49, in extract_fpc
    audio_ref, _ = librosa.load(audio_ref, sr=fs)
  File "/home/luke/.conda/envs/Amphion/lib/python3.10/site-packages/librosa/core/audio.py", line 192, in load
    y = resample(y, orig_sr=sr_native, target_sr=sr, res_type=res_type)
  File "/home/luke/.conda/envs/Amphion/lib/python3.10/site-packages/librosa/core/audio.py", line 668, in resample
    y_hat = np.apply_along_axis(
  File "<__array_function__ internals>", line 180, in apply_along_axis
  File "/home/luke/.conda/envs/Amphion/lib/python3.10/site-packages/numpy/lib/shape_base.py", line 379, in apply_along_axis
    res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
  File "/home/luke/.conda/envs/Amphion/lib/python3.10/site-packages/soxr/__init__.py", line 145, in resample
    if in_rate <= 0 or out_rate <= 0:
TypeError: '<=' not supported between instances of 'str' and 'int'

If we use 24000

$ bash egs/metrics/run.sh --reference_folder compare/ref_dir --generated_folder compare/gen_dir --dump_folder compare/dump_dir --metrics "fpc" --fs 24000
  0%|                                                                     | 0/3 [00:00<?, ?it/s]
  0%|                                                                     | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/mnt/c/users/lukec/pycharmprojects/Amphion/bins/calc_metrics.py", line 155, in <module>
    calc_metric(args.ref_dir, args.deg_dir, args.dump_dir, args.metrics, args.fs)
  File "/mnt/c/users/lukec/pycharmprojects/Amphion/bins/calc_metrics.py", line 110, in calc_metric
    score = METRIC_FUNC[metric](
  File "/mnt/c/users/lukec/pycharmprojects/Amphion/evaluation/metrics/f0/f0_pearson_coefficients.py", line 49, in extract_fpc
    audio_ref, _ = librosa.load(audio_ref, sr=fs)
  File "/home/luke/.conda/envs/Amphion/lib/python3.10/site-packages/librosa/core/audio.py", line 192, in load
    y = resample(y, orig_sr=sr_native, target_sr=sr, res_type=res_type)
  File "/home/luke/.conda/envs/Amphion/lib/python3.10/site-packages/librosa/core/audio.py", line 668, in resample
    y_hat = np.apply_along_axis(
  File "<__array_function__ internals>", line 180, in apply_along_axis
  File "/home/luke/.conda/envs/Amphion/lib/python3.10/site-packages/numpy/lib/shape_base.py", line 379, in apply_along_axis
    res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
  File "/home/luke/.conda/envs/Amphion/lib/python3.10/site-packages/soxr/__init__.py", line 145, in resample
    if in_rate <= 0 or out_rate <= 0:
TypeError: '<=' not supported between instances of 'str' and 'int'

Expected behavior

Execute without error and dump results.

Screenshots

See Reproduce part.

Environment Information

  • Operating System: Debian 12
  • Python Version: Python 3.10.13
  • Driver & CUDA Version: NVIDIA-SMI 545.36, Driver Version: 546.33, CUDA Version: 12.3
  • Error Messages and Logs: See Reproduce part.

arsity avatar Jan 15 '24 11:01 arsity