저는 분배기 모듈(spleeter)을 사용하여 오디오 파일을 처리하기 위해 웹 인터페이스(php)의 기술적 혁신을 위해 노력하고 있습니다.https://github.com/deezer/spleeter).
내 데모 애플리케이션이 작동하지 않습니다. 아래를 참조하세요. 유용한 피드백을 받은 후에(thx @cas @marcus-müller) 나는 그것으로 내 목표를 달성할 수 없다는 것을 알고 있습니다.
내가 정말로 달성하고 싶은 것은 PHP에서 'sleeter' 명령을 실행하는 것입니다.
터미널에서 루트로 실행
root@myServer:/var/www/html# spleeter separate -p spleeter:2stems -o output audio_example.mp3
INFO:spleeter:File output/audio_example/vocals.wav written succesfully
INFO:spleeter:File output/audio_example/accompaniment.wav written succesfully
PHP 결과가 없습니다
exec("spleeter separate -p spleeter:2stems -o output audio_example.mp3");
테스트를 위해 www-data 사용자로 이 명령을 실행하면 다음 오류가 발생합니다.
root@j344977:/var/www/html# sudo -u www-data spleeter separate -p spleeter:2stems -o output audio_example.mp3
Traceback (most recent call last):
File "/usr/local/bin/spleeter", line 8, in <module>
sys.exit(entrypoint())
File "/usr/local/lib/python3.6/dist-packages/spleeter/__main__.py", line 256, in entrypoint
spleeter()
File "/usr/local/lib/python3.6/dist-packages/typer/main.py", line 214, in __call__
return get_command(self)(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/typer/main.py", line 497, in wrapper
return callback(**use_params) # type: ignore
File "/usr/local/lib/python3.6/dist-packages/spleeter/__main__.py", line 114, in separate
from .separator import Separator
File "/usr/local/lib/python3.6/dist-packages/spleeter/separator.py", line 27, in <module>
from librosa.core import istft, stft
File "/usr/local/lib/python3.6/dist-packages/librosa/__init__.py", line 211, in <module>
from . import core
File "/usr/local/lib/python3.6/dist-packages/librosa/core/__init__.py", line 5, in <module>
from .convert import * # pylint: disable=wildcard-import
File "/usr/local/lib/python3.6/dist-packages/librosa/core/convert.py", line 7, in <module>
from . import notation
File "/usr/local/lib/python3.6/dist-packages/librosa/core/notation.py", line 8, in <module>
from ..util.exceptions import ParameterError
File "/usr/local/lib/python3.6/dist-packages/librosa/util/__init__.py", line 83, in <module>
from .utils import * # pylint: disable=wildcard-import
File "/usr/local/lib/python3.6/dist-packages/librosa/util/utils.py", line 1848, in <module>
def __shear_dense(X, factor=+1, axis=-1):
File "/usr/local/lib/python3.6/dist-packages/numba/core/decorators.py", line 214, in wrapper
disp.enable_caching()
File "/usr/local/lib/python3.6/dist-packages/numba/core/dispatcher.py", line 812, in enable_caching
self._cache = FunctionCache(self.py_func)
File "/usr/local/lib/python3.6/dist-packages/numba/core/caching.py", line 610, in __init__
self._impl = self._impl_class(py_func)
File "/usr/local/lib/python3.6/dist-packages/numba/core/caching.py", line 348, in __init__
"for file %r" % (qualname, source_path))
RuntimeError: cannot cache function '__shear_dense': no locator available for file '/usr/local/lib/python3.6/dist-packages/librosa/util/utils.py'
이 문제에 대한 간단한 해결책이 있습니까?
내 데모 애플리케이션 구성
루트로서 다음 명령을 실행할 수 있습니다.
root@myServer:/var/www/html# ./spleetercommand.sh
www-data에는 행운이 없습니다.
root@myServer:/var/www/html# sudo -u www-data ./spleetercommand.sh
이것은 내 설정입니다.
/var/www/html/sleetercommand.sh
#!/bin/bash
echo "--- Start spleeter ---"
/usr/local/bin/spleeter separate -p spleeter:2stems -o /var/www/html/output /var/www/html/audio_example.mp3
echo "--- End spleeter ---"
?>
/var/www/html/command.php
<?php
echo "get_current_user(): " . get_current_user();
echo "whoami: " . (exec("whoami"));
echo (exec("/var/www/html/spleetercommand.sh"));
?>
브라우저 출력 command.php
get_current_user(): root
whoami: www-data
--- End spleeter ---
/etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
/etc/sudoers.d/spleeter
www-data All=NOPASSWD: /var/www/html/spleetercommand.sh
sudoers 구문 분석 테스트
root@myServer:/etc/sudoers.d# sudo visudo -c
/etc/sudoers: parsed OK
/etc/sudoers.d/spleeter: parsed OK
(우분투 18, 아파치, PHP7)
답변1
ML 모델/분류자를 루트로 실행해야 할 이유가 없습니다. 루트가 되려고 시도하는 대신 문제를 해결해야 합니다. 진짜.
답변2
/usr/local/bin/spleeter
차라리 아래에 올려두는게 나을듯sudo
존재하다/etc/sudoers.d/spleeter
www-data All=NOPASSWD: /usr/local/bin/spleeter separate -p spleeter:2stems -o /var/www/html/output /var/www/html/*.mp3
- 전체 명령줄은 sudo와 함께 사용해야 합니다.
/var/www/html/spleetercommand.sh
삽입 하고sudo -u www-data