Когда я выполняю свой код, он показывает мне ошибку, как показано ниже, я не знаю, что это означает visqol_find.py:33 ERROR: /bin/sh: 1: visqol: not found, и я почти уверен, что visqol_value и visqol_threshold оба определены как плавающие, потому что программа отлично работает с моим профессором.
Моя система — Ubuntu 18.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






Поскольку вы не указали абсолютный путь к visqol в сценарии оболочки, ваш код не мог вызвать visqol.
Я предлагаю указать абсолютный путь к visqol.
попробуйте команду ниже в вашей оболочке (или в вашем терминале).
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("/absolute/path/visqol --reference_file ~~"
Если нет, установите «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
Вы должны собрать его из репозитория github. (github.com/google/visqol ). инструкция ( github.com/google/visqol#build).
Я изменил ответ. Я думал, что это просто пакет, который можно установить через apt.
Сообщение об ошибке от /bin/sh. Это означает, что вы ожидаете, что ваша оболочка (bash/dash/другая) выполнит скрипт Python, который не будет работать.
Вам нужно либо поставить Python shebang в качестве первой строки вашего скрипта, например.
#!/usr/bin/env python3
...
... rest of script
затем сделайте его исполняемым с помощью:
chmod +x YOURSCRIPT.PY
и запустить с:
./YOURSCRIPT.PY
Или вам нужно запустить это так, конкретно с интерпретатором Python:
python3 YOURSCRIPT.PY
В какой файл я должен поместить эту строку кода? тот, который я хочу выполнить, или тот, который будет называться как этот «visqol_find.py»?
Вы можете поместить его вверху любого/всех скриптов Python, если вам особенно не нравится печатать python3 thisscript.py и python3 thatscript.py
У меня не работает, все равно выдает ту же ошибку :(
Хорошо, пожалуйста, нажмите edit под своим вопросом и покажите, как именно вы запускаете свой скрипт вместе с полным сообщением об ошибке,
Хорошо, вы должны увидеть это сейчас
Я не могу загрузить visqol с помощью «apt install visqol» или «sudo apt install visqol» ни в терминале, ни в виртуальной среде. Пакет не загружается из командной строки