pydub audiosegement gives a FileNotFoundError - python

I'm trying to work with pydub to get the times of each word spoken in an audio file, but python throws me a FileNotFoundError
The code:
from pydub import AudioSegment
from pydub.silence import detect_nonsilent
path = "E:/PyApps/New/PythonApplication1/OSR_us_000_0010_8k.wav"
audio_segment = AudioSegment.from_wav(path)
The error:
Traceback (most recent call last):
File "E:\PyApps\New\PythonApplication1\module1.py", line 5, in
audio_segment = AudioSegment.from_wav(path)
File "C:\Users\Dean\AppData\Local\Programs\Python\Python39\lib\site-packages\pydub\audio_segment.py", line 808, in from_wav
return cls.from_file(file, 'wav', parameters=parameters)
File "C:\Users\Dean\AppData\Local\Programs\Python\Python39\lib\site-packages\pydub\audio_segment.py", line 728, in from_file
info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
File "C:\Users\Dean\AppData\Local\Programs\Python\Python39\lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
File "C:\Users\Dean\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Dean\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
whats weird is that I've got all the files specified in the error in the right folder but it still can't find them for some reason.

Related

When I used subprocess.py ,it was happened that(hp, ht, pid, tid = _winapi.CreateProcess(executable, args, OSError: [WinError 193] %1))

When I use speechbrain to do work with rffm files, I get the following error
speechbrain.core - Exception:
Traceback (most recent call last):
File "F:/Speech/speechbrain/recipes/AMI/Diarization/experiment.py", line 647, in <module>
best_pval = dev_pval_tuner(full_meta, "dev")
File "F:/Speech/speechbrain/recipes/AMI/Diarization/experiment.py", line 364, in dev_pval_tuner
MS, FA, SER, DER_ = DER(
File "D:\anaconda\envs\speech_brain\lib\site-packages\speechbrain\utils\DER.py", line 108, in DER
stdout = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
File "D:\anaconda\envs\speech_brain\lib\subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "D:\anaconda\envs\speech_brain\lib\subprocess.py", line 489, in run
with Popen(*popenargs, **kwargs) as process:
File "D:\anaconda\envs\speech_brain\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "D:\anaconda\envs\speech_brain\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
OSError: [WinError 193] %1 is not a valid Win32 application
I try to change the version of python, numpy version of python, and change 32-bit instead of 64-bit, but none of them work.

Guesslangtools: FileNotFoundError: [Errno 2] No such file or directory: 'timeout'

I'm using Guesslangtools on my Mac in order to create a dataset.
When the execution reaches the step "Download chosen repositories" I'm hitting the following error:
Could this error be in any way related to Python 9?
I would appreciate suggestions on how to fix this.
"""
Traceback (most recent call last):
File "/usr/local/Cellar/python#3.9/3.9.13/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/usr/local/lib/python3.9/site-packages/guesslangtools/common.py", line 264, in _apply
return method(item, *other_args, **keywords)
File "/usr/local/lib/python3.9/site-packages/guesslangtools/workflow/github_repositories.py", line 130, in _clone_repository
result = run(command, stdout=PIPE, stderr=PIPE)
File "/usr/local/Cellar/python#3.9/3.9.13/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/local/Cellar/python#3.9/3.9.13/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/local/Cellar/python#3.9/3.9.13/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'timeout'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/bin/gltool", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/guesslangtools/__main__.py", line 153, in main
run_workflow(config)
File "/usr/local/lib/python3.9/site-packages/guesslangtools/app.py", line 15, in run_workflow
github_repositories.download(config)
File "/usr/local/lib/python3.9/site-packages/guesslangtools/common.py", line 175, in wrapped
result = func(config, *args, **kw)
File "/usr/local/lib/python3.9/site-packages/guesslangtools/workflow/github_repositories.py", line 105, in download
for step, row in enumerate(pool_map(_clone_repository, rows, config), 1):
File "/usr/local/lib/python3.9/site-packages/guesslangtools/common.py", line 255, in pool_map
for result in pool.imap_unordered(_apply, iterable):
File "/usr/local/Cellar/python#3.9/3.9.13/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/pool.py", line 870, in next
raise value
FileNotFoundError: [Errno 2] No such file or directory: 'timeout'```
it’s likely because the GNU timeout program does not exist on the system that is running the test. timeout is part of the GNU Coreutils, so make sure that is installed on the system.
$ brew install coreutils # Mac OS X
then add a "gnubin" directory to your PATH, for example:
$ export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"

"[WinError 2] The system cannot find the file specified" Error using pyvirtualdisplay in python

I'm getting the following error when i try to run this simple python code
from pyvirtualdisplay import Display
disp = Display()
disp.start()
Error:
Traceback (most recent call last):
File "C:\Users\Saeed\Desktop\disp.py", line 4, in <module>
disp = Display()
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python310\lib\site-packages\pyvirtualdisplay\display.py", line 54, in __init__
self._obj = cls(
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python310\lib\site-packages\pyvirtualdisplay\xvfb.py", line 44, in __init__
AbstractDisplay.__init__(
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python310\lib\site-packages\pyvirtualdisplay\abstractdisplay.py", line 85, in __init__
helptext = get_helptext(program)
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python310\lib\site-packages\pyvirtualdisplay\util.py", line 13, in get_helptext
p = subprocess.Popen(
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Saeed\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1435, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
Any help will be appreciated.

PermissionError: [Errno 13] when using tkinter for an image

Hello I am trying to make a python script that takes an image file from a computer and turn it into text. At the moment, I have the following code
from tkinter import Tk
from tkinter.filedialog import askopenfilename
import pytesseract
Tk().withdraw()
filename = askopenfilename()
print(filename)
pytesseract.pytesseract.tesseract_cmd = filename
print(pytesseract.image_to_string(filename))
However this gives me the error
Traceback (most recent call last):
File "main.py", line 11, in <module>
print(pytesseract.image_to_string(filename))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytesseract/pytesseract.py", line 409, in image_to_string
return {
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytesseract/pytesseract.py", line 412, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytesseract/pytesseract.py", line 287, in run_and_get_output
run_tesseract(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytesseract/pytesseract.py", line 258, in run_tesseract
raise e
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pytesseract/pytesseract.py", line 255, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/Users/william/theimage.jpg'
What am I doing wrong?
this: pytesseract.pytesseract.tesseract_cmd = filename is absolutely wrong.
tesseract_cmd should have your tesseract engine executable path.
you need to find where you installed tesseract.
pytesseract.pytesseract.tesseract_cmd = <path_to_tesseract_engine>
# example
# pytesseract.pytesseract.tesseract_cmd = "/some_folder1/some_folder2/...
# /<where_you_installed_tesseract_cmd>/tesseract.<whatever_is_the_extension_for_executables_on_mac>"
you get permission error because you set the tesseract_cmd to link the path to your image and when you actually use pytesseract.image_to_string(<your_image>) ofcourse it raises permission denied because the image is used by the tesseract_cmd process.
after you set your engine.
this is gonna be fine
print(pytesseract.image_to_string(filename))

textract failed with exit code 127: pdftotext on windows 10

I am trying to run a python program on a windows 10 machine with which I am trying to read and convert PDF files. However every time I run the program I get the following error. I have not found out how to resolve this yet. Is there anyone who can help me please :)
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\utils.py", line 82, in run
pipe = subprocess.Popen(
File "C:\Users\trpfinance\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\trpfinance\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\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "EinkaufRGWindows.py", line 40, in InkoopRekeningen
text = textract.process(str(importfolder) + str(i))
File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\__init__.py", line 77, in process
return parser.process(filename, encoding, **kwargs)
File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\utils.py", line 46, in process
byte_string = self.extract(filename, **kwargs)
File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\pdf_parser.py", line 28, in extract
raise ex
File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\pdf_parser.py", line 20, in extract
return self.extract_pdftotext(filename, **kwargs)
File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\pdf_parser.py", line 43, in extract_pdftotext
stdout, _ = self.run(args)
File "C:\Users\trpfinance\AppData\Local\Programs\Python\Python38-32\lib\site-packages\textract\parsers\utils.py", line 90, in run
raise exceptions.ShellError(
textract.exceptions.ShellError: The command `pdftotext //Mac/Home/Desktop/Wickey Einkauf Test/Rekeningen/Lekkerkerker_ - 20803471.pdf -` failed with exit code 127
------------- stdout -------------
------------- stderr -------------

Categories

Resources