skip to Main Content

When I execute my code it shows me error as below, I don’t know what is this visqol_find.py:33 ERROR: /bin/sh: 1: visqol: not found meaning, and I pretty sure that visqol_value and visqol_threshold are both defined as float because the program is working fine with my professor.

My system is Ubuntu 18.04 and python is 3.6.12.

This is code for visqol_value

def visqol(reference_file: str, degraded_file: str, visqol_model_path: str = __visqol_model_path__) -> float:
    status, output = subprocess.getstatusoutput("visqol --reference_file {} --degraded_file {} --similarity_to_quality_model {} --use_speech_mode".format(reference_file, degraded_file, visqol_model_path))
    if status != 0:
        for _line_ in output.split('n'):
            logger.error(_line_)
        raise RuntimeError("VISQOL Command-Line Error.")
    visqol_score = None
    for output_line in output.split("n"):
        if output_line.startswith('MOS-LQO:'):
            visqol_score = float(output_line.split()[1])
    if visqol_score is not None:
        return visqol_score
    raise RuntimeError("VISQOL Command-Line Error.")
        visqol_value = visqol(clip_file, adversarial_path)
        if visqol_value < visqol_threshold:
            right_bound = potential_delta
            if _delete_failed_wav_:  # delete
                for _file_ in glob.glob(adversarial_path[:-4] + "*"):
                    os.remove(_file_)
            logger.debug("VISQOL Exceeds for music clip '{}' with 'delta_db={}'.".format(clip_name, potential_delta))
            continue

This is code for visqol_threshold

def get_visqol_threshold(formant_weight: Union[list, np.ndarray], phoneme_num: int) -> float:
    formant_weight = np.array(formant_weight)
    _alpha = 0.95  # The higher the value of _alpha and _beta is, the faster the visqol threshold decreases.
    _beta = 8.0
    _theta = 10.0
    o = np.sum(formant_weight != 0.)
    if o == 5:
        base = 1.7
    elif o == 4:
        base = 1.8
    elif o == 3:
        base = 2.2
    else:
        if formant_weight[1] < 0.75:
            base = 2.3
        else:
            base = 2.25

    return base * (_alpha ** (max((phoneme_num - _theta) / _beta, 0.)))

I would like to know how I should fix it?
Since I am running this project in a virtual python environment, is it possible that it is because I put visqol in the wrong place, and if so, where should I download visqol to

The program works but keeps looping with these two error messages until I manually terminate it

(.venv) dunliu@dun:~/research/Phantom-of-Formants-master$ python3 2022gen_100song_bing_001.py 
2022-11-13 17:23:58 2022gen_100song_bing_001.py:433 WARNING: The destination folder './task/weather1/generate/0490c9606d8e333e' will be removed. Please backup this folder, and then enter 'Y' to continue, or others to exit...
y
2022-11-13 17:24:01 2022gen_100song_bing_001.py:437 INFO: The destination folder './task/weather1/generate/0490c9606d8e333e' was removed.
2022-11-13 17:24:01 2022gen_100song_bing_001.py:325 INFO: ********************    Start Binary-search Generation.    ********************
2022-11-13 17:24:01 visqol_find.py:34 ERROR: /bin/sh: 1: visqol: not found
2022-11-13 17:24:01 utils.py:361 ERROR: program exit!
Traceback (most recent call last):
  File "/home/dunliu/research/Phantom-of-Formants-master/utils.py", line 357, in wrapper
    return function(*args, **kwargs)
  File "/home/dunliu/research/Phantom-of-Formants-master/visqol_find.py", line 35, in visqol
    raise RuntimeError("VISQOL Command-Line Error.")
RuntimeError: VISQOL Command-Line Error.
2022-11-13 17:24:01 utils.py:361 ERROR: program exit!
Traceback (most recent call last):
  File "/home/dunliu/research/Phantom-of-Formants-master/utils.py", line 357, in wrapper
    return function(*args, **kwargs)
  File "2022gen_100song_bing_001.py", line 257, in generate
    if visqol_value < visqol_threshold:
TypeError: '<' not supported between instances of 'NoneType' and 'float'
2022-11-13 17:24:01 visqol_find.py:34 ERROR: /bin/sh: 1: visqol: not found
2022-11-13 17:24:01 utils.py:361 ERROR: program exit!
Traceback (most recent call last):
  File "/home/dunliu/research/Phantom-of-Formants-master/utils.py", line 357, in wrapper
    return function(*args, **kwargs)
  File "/home/dunliu/research/Phantom-of-Formants-master/visqol_find.py", line 35, in visqol
    raise RuntimeError("VISQOL Command-Line Error.")
RuntimeError: VISQOL Command-Line Error.
2022-11-13 17:24:01 utils.py:361 ERROR: program exit!
Traceback (most recent call last):
  File "/home/dunliu/research/Phantom-of-Formants-master/utils.py", line 357, in wrapper
    return function(*args, **kwargs)
  File "2022gen_100song_bing_001.py", line 257, in generate
    if visqol_value < visqol_threshold:
TypeError: '<' not supported between instances of 'NoneType' and 'float'

after I terminate it, it shows

^CTraceback (most recent call last):
  File "2022gen_100song_bing_001.py", line 448, in <module>
    binary_generation_task()
  File "2022gen_100song_bing_001.py", line 444, in binary_generation_task
    binary_generation(params)
  File "2022gen_100song_bing_001.py", line 395, in binary_generation
    generate(_wake_up_analysis_file_, _command_analysis_file_, _clip_file_, output_folder, params)
  File "/home/dunliu/research/Phantom-of-Formants-master/utils.py", line 359, in wrapper
    raise _err
  File "/home/dunliu/research/Phantom-of-Formants-master/utils.py", line 357, in wrapper
    return function(*args, **kwargs)
  File "2022gen_100song_bing_001.py", line 251, in generate
    adversarial_path = gen_by_command(delta_db_list, bandwidth_list, command_analysis_file, clip_file, output_folder, adversarial_filename, params)
  File "/home/dunliu/research/Phantom-of-Formants-master/utils.py", line 359, in wrapper
    raise _err
  File "/home/dunliu/research/Phantom-of-Formants-master/utils.py", line 357, in wrapper
    return function(*args, **kwargs)
  File "/home/dunliu/research/Phantom-of-Formants-master/formant_processor.py", line 688, in gen_by_command
    command_filter_list = generate_filter(command_formant_list, m_sample_rate, bandwidth, min_fre, max_fre, filter_order, reserved_fre_gap_ratio)
  File "/home/dunliu/research/Phantom-of-Formants-master/formant_processor.py", line 356, in generate_filter
    signal.butter(f_order, [_s_fre_, _e_fre_], btype='band', output='sos')
  File "/home/dunliu/research/Phantom-of-Formants-master/.venv/lib/python3.6/site-packages/scipy/signal/filter_design.py", line 2894, in butter
    output=output, ftype='butter', fs=fs)
  File "/home/dunliu/research/Phantom-of-Formants-master/.venv/lib/python3.6/site-packages/scipy/signal/filter_design.py", line 2407, in iirfilter
    return zpk2sos(z, p, k)
  File "/home/dunliu/research/Phantom-of-Formants-master/.venv/lib/python3.6/site-packages/scipy/signal/filter_design.py", line 1447, in zpk2sos
    z = np.concatenate(_cplxreal(z))
  File "/home/dunliu/research/Phantom-of-Formants-master/.venv/lib/python3.6/site-packages/scipy/signal/filter_design.py", line 887, in _cplxreal
    z = atleast_1d(z)
  File "<__array_function__ internals>", line 6, in atleast_1d
  File "/home/dunliu/research/Phantom-of-Formants-master/.venv/lib/python3.6/site-packages/numpy/core/shape_base.py", line 25, in atleast_1d
    @array_function_dispatch(_atleast_1d_dispatcher)
KeyboardInterrupt

2

Answers


  1. Because you didn’t specify the visqol’s absolute path in the shell script, your code couldn’t call the visqol.

    I suggest specifying the visqol’s absolute path.

    try the command below in your shell ( Or your terminal ).

    which visqol
    

    If the path exist, then replace "visqol" in the code below with the result above.

    status, output = subprocess.getstatusoutput("visqol --reference_file {} --degraded_file {} --similarity_to_quality_model {} --use_speech_mode".format(reference_file, degraded_file, visqol_model_path))
    

    It looks like "~~ getstatusoutput("/absolute/path/visqol –reference_file ~~"

    If not, install "visqol" via the code below in your shell (OR terminal) and try the solution above.

    # install bazel to build visqol
    # https://bazel.build/install/ubuntu
    
    sudo apt install apt-transport-https curl gnupg
    sudo apt update && sudo apt install bazel
    sudo apt update && sudo apt full-upgrade
    
    # install numpy python library.
    # https://github.com/google/visqol#linuxmac-build-instructions
    
    pip install numpy
    
    # download source code and build visqol
    # https://github.com/google/visqol#linuxmac-build-instructions
    
    git clone https://github.com/google/visqol.git
    cd visqol
    bazel build :visqol -c opt
    
    
    Login or Signup to reply.
  2. The error message is from /bin/sh. That means you are expecting your (bash/dash/other) shell to execute a Python script which isn’t going to work.

    You need to either put a Python shebang as the first line of your script, e.g.

    #!/usr/bin/env python3
    ...
    ... rest of script
    

    then make it executable with:

    chmod +x YOURSCRIPT.PY
    

    and run with:

    ./YOURSCRIPT.PY
    

    Or, you need to start it like this, specifically with the Python interpreter:

    python3 YOURSCRIPT.PY
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search