Closed UmairPar closed 5 years ago
Hi @UmairPar, you should run the script directly with python <script.py>
.
Hey, I am getting the same error. Running directly with python
Using TensorFlow backend usage: predict.py [-h] location predict.py: error: the following arguments are required: location
plate_recognition.py: error: the following arguments are required: --api, FILE what does this error mean? Do I need to provide my file name? Below is the line of code: parser.add_argument('FILE', help='Path to video.')
Arguments are passed by adding two leading hyphens. So, when it says
following arguments are required: example_arg
your code should be
parser.add_argument('--example_arg', 'arg1')
. Note the two leading hyphens --
The issues seem to have been addressed in comments above.
Hi friends So I am new to python and maybe asking a simple question. this errors are occured in my code. ERROR:the following arguments are required: audio_path, target_path
the code is here. """ A utility script used for converting audio samples to be suitable for feature extraction """
import os.path
def convert_audio(audio_path, target_path, remove=False):
"""This function sets the audio audio_path
to:
one audio channel ( mono ) Params: audio_path (str): the path of audio wav file you want to convert target_path (str): target path to save your new converted wav file remove (bool): whether to remove the old file after converting Note that this function requires ffmpeg installed in your system."""
os.system(f"ffmpeg -i {audio_path} -ac 1 -ar 16000 {target_path}")
if remove: os.remove(audio_path)
def convert_audios(path, target_path, remove=False): """Converts a path of wav files to:
one audio channel ( mono )
and then put them into a new folder called target_path
Params:
audio_path (str): the path of audio wav file you want to convert
target_path (str): target path to save your new converted wav file
remove (bool): whether to remove the old file after converting
Note that this function requires ffmpeg installed in your system."""
for dirpath, dirnames, filenames in os.walk(path): for dirname in dirnames: dirname = os.path.join(dirpath, dirname) target_dir = dirname.replace(path, target_path) if not os.path.isdir(target_dir): os.mkdir(target_dir)
for dirpath, _, filenames in os.walk(path): for filename in filenames: file = os.path.join(dirpath, filename) if file.endswith(".wav"):
target_file = file.replace(path, target_path)
convert_audio(file, target_file, remove=remove)
if name == "main": import argparse parser = argparse.ArgumentParser(description="""Convert ( compress ) wav files to 16MHz and mono audio channel ( 1 channel ) This utility helps for compressing wav files for training and testing""") parser.add_argument("audio_path", help="Folder that contains wav files you want to convert") parser.add_argument("target_path", help="Folder to save new wav files") parser.add_argument("-r", "--remove", type=bool, help="Whether to remove the old wav file after converting", default=False)
args = parser.parse_args()
audio_path = args.audio_path
target_path = args.target_path
if os.path.isdir(audio_path):
if not os.path.isdir(target_path):
os.makedirs(target_path)
convert_audios(audio_path, target_path, remove=args.remove)
elif os.path.isfile(audio_path) and audio_path.endswith(".wav"):
if not target_path.endswith(".wav"):
target_path += ".wav"
convert_audio(audio_path, target_path, remove=args.remove)
else:
raise TypeError("The audio_path file you specified isn't appropriate for this operation")
Hey guys,
So I am new to python and maybe asking a simple question. I wanted to use the google API to do speech to text for audio files longer than a minute. So I copied and pasted the code into python and I get the error:
usage: test.py [-h] path test.py: error: the following arguments are required: path An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py:2889: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D. warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
When I do the traceback I get this:
Traceback (most recent call last):
File "", line 1, in
runfile('C:/Users/MGMT/.spyder-py3/test.py', wdir='C:/Users/MGMT/.spyder-py3')
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/MGMT/.spyder-py3/test.py", line 82, in
args = parser.parse_args()
File "C:\ProgramData\Anaconda3\lib\argparse.py", line 1730, in parse_args args, argv = self.parse_known_args(args, namespace)
File "C:\ProgramData\Anaconda3\lib\argparse.py", line 1762, in parse_known_args namespace, args = self._parse_known_args(args, namespace)
File "C:\ProgramData\Anaconda3\lib\argparse.py", line 1997, in _parse_known_args ', '.join(required_actions))
File "C:\ProgramData\Anaconda3\lib\argparse.py", line 2389, in error self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
File "C:\ProgramData\Anaconda3\lib\argparse.py", line 2376, in exit _sys.exit(status)
SystemExit: 2
What should I do?