当我执行我的代码时,它向我显示了如下所示的错误,我不知道这个visqol_find.py:33 ERROR: /bin/sh: 1: visqol: not found
是什么意思,而且我很确定visqol_value
和visqol_threshold
都被定义为浮点数,因为这个程序与我的教授合作得很好。
我的系统是Ubuntu18.04,python是3.6.12。
这是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
这是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.)))
我想知道我该怎么修理它?由于我在虚拟python环境中运行这个项目,是否可能是因为我把visqol放在了错误的位置,如果是的话,我应该从哪里下载visqol到
该程序工作正常,但一直循环使用这两条错误消息,直到我手动终止它为止。
(.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'
在我终止它之后,它显示
^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
发布于 2022-11-13 08:12:10
因为您没有在shell脚本中指定visqol的绝对路径,所以您的代码无法调用visqol。
我建议指定visqol的绝对路径。
在shell (或终端)中尝试下面的命令。
which visqol
如果存在路径,那么将下面代码中的"visqol“替换为上面的结果。
status, output = subprocess.getstatusoutput("visqol --reference_file {} --degraded_file {} --similarity_to_quality_model {} --use_speech_mode".format(reference_file, degraded_file, visqol_model_path))
它看起来像是"~~ getstatusoutput(“)/绝对值/路径/visqol
如果没有,请通过shell (或终端)中的下面代码安装"visqol“,并尝试上面的解决方案。
# 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
发布于 2022-11-13 08:28:37
错误消息来自/bin/sh
。这意味着您希望您的(bash/破折号/其他) shell执行一个不起作用的Python脚本。
您需要将作为脚本的第一行。
#!/usr/bin/env python3
...
... rest of script
然后通过以下方式使其可执行:
chmod +x YOURSCRIPT.PY
并与以下人员一起奔跑:
./YOURSCRIPT.PY
或者,您需要像这样启动它,特别是使用Python解释器:
python3 YOURSCRIPT.PY
https://stackoverflow.com/questions/74419277
复制相似问题