PermissionError: [Errno 13] Permission denied failure - python

I have never used python before and I want to build a project I found on github but I have not solved a problem there for 2 hours. I don't think it's a problem that I've installed all the packages individually. I've applied all the necessary documents that he narrates, but when I run the following command, I get an error How can I solve this error?
https://github.com/tsurumeso/vocal-remover
Run
python inference.py --input C:\Users\Berkay\Desktop\vocal-remover
error output
PS C:\Users\Berkay\Desktop\vocal-remover> python inference.py --input C:\Users\Berkay\Desktop\vocal-remover loading model... done
C:\Users\Berkay\AppData\Local\Programs\Python\Python37\lib\site-packages\librosa\core\audio.py:146: UserWarning: PySoundFile failed. Trying audioread instead.
warnings.warn('PySoundFile failed. Trying audioread instead.')
loading wave source... Traceback (most recent call last):
File "C:\Users\Berkay\AppData\Local\Programs\Python\Python37\lib\site-packages\librosa\core\audio.py", line 129, in load
with sf.SoundFile(path) as sf_desc:
File "C:\Users\Berkay\AppData\Local\Programs\Python\Python37\lib\site-packages\soundfile.py", line 629, in __init__
self._file = self._open(file, mode_int, closefd)
File "C:\Users\Berkay\AppData\Local\Programs\Python\Python37\lib\site-packages\soundfile.py", line 1184, in _open
"Error opening {0!r}: ".format(self.name))
File "C:\Users\Berkay\AppData\Local\Programs\Python\Python37\lib\site-packages\soundfile.py", line 1357, in _error_check
raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening 'C:\\Users\\Berkay\\Desktop\\vocal-remover': System error.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "inference.py", line 39, in <module>
args.input, args.sr, False, dtype=np.float32, res_type='kaiser_fast')
File "C:\Users\Berkay\AppData\Local\Programs\Python\Python37\lib\site-packages\librosa\core\audio.py", line 147, in load
y, sr_native = __audioread_load(path, offset, duration, dtype)
File "C:\Users\Berkay\AppData\Local\Programs\Python\Python37\lib\site-packages\librosa\core\audio.py", line 171, in __audioread_load
with audioread.audio_open(path) as input_file:
File "C:\Users\Berkay\AppData\Local\Programs\Python\Python37\lib\site-packages\audioread\__init__.py", line 111, in audio_open
return BackendClass(path)
File "C:\Users\Berkay\AppData\Local\Programs\Python\Python37\lib\site-packages\audioread\rawread.py", line 62, in __init__
self._fh = open(filename, 'rb')
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\Berkay\\Desktop\\vocal-remover'

I found the solution to the problem.
False
python inference.py --input C:\Users\Berkay\Desktop\vocal-remover
That's right
python inference.py --input C:\Users\Berkay\Desktop\vocal-remover\music.mp3

I think the problem is that your input is a directory, while I bet it should be some audio file. You should do:
inference.py --input path/to/your/audio.wav

Related

Error in librosa.load('path.webm') RuntimeError: File contains data in an unknown format

I am trying to load sound files on a python script.
I installed, loaded the right version of modules, imported successfully librosa and soundfile, and even ffmpeg (which I found was a solution to this same error for mp3 files)
import os
import json
from scipy import signal
import librosa
[...]
y, sr = librosa.load(directory_path + filename + '.webm', mono = True)
My code works on notebooks (Kaggle) but somehow, and I can't figure out why, it doesn't work when uploaded on a computer cluster. And I really need the cluster for its computational power/memory. :/
The error:
Traceback (most recent call last):
File "/cluster/apps/nss/gcc-6.3.0/python/3.8.5/x86_64/lib64/python3.8/site-packages/librosa/core/audio.py", line 146, in load
with sf.SoundFile(path) as sf_desc:
File "/cluster/home/.local/lib/python3.8/site-packages/soundfile.py", line 740, in __init__
self._file = self._open(file, mode_int, closefd)
File "/cluster/home/.local/lib/python3.8/site-packages/soundfile.py", line 1264, in _open
_error_check(_snd.sf_error(file_ptr),
File "/cluster/home/.local/lib/python3.8/site-packages/soundfile.py", line 1455, in _error_check
raise RuntimeError(prefix + _ffi.string(err_str).decode('utf-8', 'replace'))
RuntimeError: Error opening 'input/00092.webm': File contains data in an unknown format.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "analysis_python.py", line 47, in <module>
y,sr = librosa.load(directory_path + filename + '.webm')
File "/cluster/apps/nss/gcc-6.3.0/python/3.8.5/x86_64/lib64/python3.8/site-packages/librosa/core/audio.py", line 163, in load
y, sr_native = __audioread_load(path, offset, duration, dtype)
File "/cluster/apps/nss/gcc-6.3.0/python/3.8.5/x86_64/lib64/python3.8/site-packages/librosa/core/audio.py", line 187, in __audioread_load
with audioread.audio_open(path) as input_file:
File "/cluster/apps/nss/gcc-6.3.0/python/3.8.5/x86_64/lib64/python3.8/site-packages/audioread/__init__.py", line 116, in audio_open
raise NoBackendError()
audioread.exceptions.NoBackendError
I perused the internet for a solution but no luck. Thank you for your help in advance.

forced alignment with aneas

I am trying to build a simple dataset for speech recognition using aneas, following the instruction here. However I'm stuck at the forced alignment, here is my code
from aeneas.executetask import ExecuteTask
from aeneas.task import Task
import os
import numpy
config_string = "task_language=eng | is_text_type=plain | os_task_file_format=json"
task = Task (config_string=config_string)
task.audio_file_path_absolute = "D:/documents/AI/open_door.mp3"
task.text_file_path_absolute = "D:/documents/AI/open_door.txt"
task.sync_map_file_path_absolute = "D:/documents/AI/syncmap.json"
ExecuteTask(task).execute()
task.output_sync_map_file()
Which gives the following error:
Traceback (most recent call last):
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\ffprobewrapper.py", line 222, in read_properties
proc = subprocess.Popen(
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\audiofile.py", line 357, in read_properties
properties = FFPROBEWrapper(
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\ffprobewrapper.py", line 233, in read_properties
self.log_exc(u"Unable to call the '%s' ffprobe executable" % (self.rconf[RuntimeConfiguration.FFPROBE_PATH]), exc, True, FFPROBEPathError)
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\logger.py", line 351, in log_exc
raise raise_type(raise_message)
aeneas.ffprobewrapper.FFPROBEPathError: Unable to call the 'ffprobe' ffprobe executable : [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\documents\AI\forced_alignment.py", line 9, in <module>
task.audio_file_path_absolute = "D:/documents/AI/open_door.mp3"
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\task.py", line 120, in audio_file_path_absolute
self._populate_audio_file()
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\task.py", line 241, in _populate_audio_file
self.audio_file.read_properties()
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\audiofile.py", line 363, in read_properties
self.log_exc(u"Unable to call ffprobe executable", None, True, AudioFileProbeError)
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\logger.py", line 351, in log_exc
raise raise_type(raise_message)
aeneas.audiofile.AudioFileProbeError: Unable to call ffprobe executable
[Finished in 0.4s]
Intuitively, I think it is because of the file paths, but changing it doesn't seem to work. I have never worked with python before so show me where I did wrong. Thank you.
I'm pretty sure it's because ffprobe isn't in your system's environmental variables.
Have you tried running python -m aeneas.diagnostics and is ffprobe in your path? Look into adding programs to your Path/system environment variables.

Getting intermittent write error while extracting files from zip archive

I have a small application that I have made. It basically copies a zip file from a network location to the computer that is running the application, unzips it in a folder and then creates a shortcut on the desktop.
Most of the time (I'd say about 80%) it works as intended. The other 20% of the time the stack trace it says it cannot create a file. It is always the same (_bz2.pyd). If I close it and run it again it works fine after this happens.
Anyone have any ideas of what is going on? Here is the code that extracts the file. I've even made the script try and extract the file, check if it worked, try and extract the file again. This hasn't solved the issue:
print ('uncompressing databases. This takes a few minutes')
# file_name = settings.working_folder + r'\UAT_Databases.zip'
temp_name = settings_dict['working_folder'] + settings_dict['file_name']
zip_ref = zipfile.ZipFile(temp_name, 'r')
zip_ref.extractall(settings_dict['install_folder'])
zip_ref.close()
logr.info('unzipped databases')
Here is the stack trace:
Traceback (most recent call last):
File "temp_installer.py", line 141, in unzip_databases
File "zipfile.py", line 1347, in extractall
File "zipfile.py", line 1335, in extract
File "zipfile.py", line 1398, in _extract_member
PermissionError: [Errno 13] Permission denied: 'C:\\TempApps\\Temp_application\\_bz2.pyd'
2020-03-03 11:36:25,697 : ERROR : __main__ : could not unzip databases
Traceback (most recent call last):
File "temp_installer.py", line 141, in unzip_databases
File "zipfile.py", line 1347, in extractall
File "zipfile.py", line 1335, in extract
File "zipfile.py", line 1398, in _extract_member
PermissionError: [Errno 13] Permission denied: 'C:\\TempApps\\Temp_application\\_bz2.pyd'

PyUSB on macOS: Access denied (insufficient permissions)

I tried running code as root, this is not helped.
I need raw access to usb device, not HID!
Traceback (most recent call last):
File "hiqos.py", line 20, in <module>
alternate_setting = usb.control.get_interface(device,interface_number)
File "/usr/local/lib/python2.7/site-packages/usb/control.py", line 244, in get_interface
data_or_wLength = 1)[0]
File "/usr/local/lib/python2.7/site-packages/usb/core.py", line 1034, in ctrl_transfer
self._ctx.managed_claim_interface(self, interface_number)
File "/usr/local/lib/python2.7/site-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/usb/core.py", line 167, in managed_claim_interface
self.backend.claim_interface(self.handle, i)
File "/usr/local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 811, in claim_interface
_check(self.lib.libusb_claim_interface(dev_handle.handle, intf))
File "/usr/local/lib/python2.7/site-packages/usb/backend/libusb1.py", line 595, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 13] Access denied (insufficient permissions)
I had the same error. I've also tried
sudo kextload -bundle-id com.apple.driver.AppleUSBFTDI
but my MacBook can't find it, although it was supposed to work for High Sierra. The only real thing I've been able to do is read input from /dev/disk3 after unmounting it by:
sudo diskutil unmountdisk /dev/disk3
and then
sudo cat /dev/disk3 | hexdump

Is there a workaround for an [Error 18]: invalid cross-device link while calling 'pip' with Popen?

I am trying to create a GUI for working with the pip command with a text editor. Currently I am receiving an [Error 18]: Invalid cross-device link which traces back to os.rename which my program does not explicitly call.
I believe that this error occurs because pip is trying to call on a temporary file located on the /tmp/ file system and the actual folders are on the /usr/ file system (same computer different mount points). I have tried to resolve this by creating a new temporary directory in my current working directory via tempfile.TemporaryDirectory(dir='./') and feeding that into my Popen(..., cwd=NewTempDir). I have also tried setting the os.environ['TMPDIR'] = NewTempDir and both of these still lead to the Error 18.
self.tmp = tempfile.TemporaryDirectory(dir='./')
os.environ['TMPDIR'] = self.tmp
....
self.sp = subprocess.Popen([sys.executable, '-m', 'pip', \
pip_dict['process'], pip_dict['package']], \
stdout=subprocess.PIPE, stdin=subprocess.PIPE, \
cwd=self.tmp.name)
....
while True:
stdout = self.sp.stdout.read(1)
self.stdout += stdout
print(self.stdout)
if b'Proceed (y/n)?' in self.stdout:
try:
print('attempting response')
self.sp.stdin.write(b'y\n')
self.sp.stdin.flush()
break
except:
print('stdin write failed')
I expect the output to be the uninstalling of the named package.
My current output is:
Exception:
Traceback (most recent call last):
File "/usr/lib/python3.7/shutil.py", line 563, in move
os.rename(src, real_dst)
OSError: [Errno 18] Invalid cross-device link:
'/usr/lib/python3.7/site-packages/anytree' -> '/tmp/pip-
uninstall-ye0w908_'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.7/site-\
packages/pip/_internal/cli/base_command.py", line 179, in
main
status = self.run(options, args)
File "/usr/lib/python3.7/site-
packages/pip/_internal/commands/uninstall.py", line 75, in run
auto_confirm=options.yes, verbose=self.verbosity > 0,
File "/usr/lib/python3.7/site-
packages/pip/_internal/req/req_install.py", line 817, in uninstall
uninstalled_pathset.remove(auto_confirm, verbose)
File "/usr/lib/python3.7/site-
packages/pip/_internal/req/req_uninstall.py", line 360, in remove
moved.stash(path)
File "/usr/lib/python3.7/site-
packages/pip/_internal/req/req_uninstall.py", line 257, in stash
renames(path, new_path)
File "/usr/lib/python3.7/site-packages/pip/_internal/utils/misc.py",
line 303, in renames
shutil.move(old, new)
File "/usr/lib/python3.7/shutil.py", line 575, in move
rmtree(src)
File "/usr/lib/python3.7/shutil.py", line 491, in rmtree
_rmtree_safe_fd(fd, path, onerror)
File "/usr/lib/python3.7/shutil.py", line 449, in _rmtree_safe_fd
onerror(os.unlink, fullname, sys.exc_info())
File "/usr/lib/python3.7/shutil.py", line 447, in _rmtree_safe_fd
os.unlink(entry.name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'search.py'
I do receive print("attempting response") before the code breaks.
Here is the link to the full program file... https://github.com/rscales02/porcupine/blob/pipgui/porcupine/plugins/pip_plugin.py
Thanks in advance!

Categories

Resources