I know it's very difficult to understand my issue, but I'll try my best to explain.
So I've cloned a repository from Github and working on it.
When I run the program without any arguments, it works fine
python main.py --audio
works fine.
But when I try to pass my own file, it shows an error.
python main.py --audio myaudio.wav
shows an error saying "FileNotFoundError: [Errno 2] No such file or directory: '<File Path/m'"
Notice how it only takes the first character from my argument?
In the code, for default mode, it's something like:
(args.py)parser.add_argument('--audio', default=['default_audio.wav'], type=list)
and it works fine.
So naturally, I tried to add '[]' to my file name
python main.py --audio [myaudio.wav]
Shows an error too which says "FileNotFoundError: [Errno 2] No such file or directory: '<File Path/['"
See, here it took only the first character of my provided argument i.e. '['
And the file IS there. No spelling mistakes in file name either.
Any help would be very much appreciated.
Asked
Active
Viewed 126 times
1

AdGo
- 11
- 1
-
Welcome to StackOverflow Advait. Is there any way that you could add a link to the repository, so that we can have a closer look? I suspect that this is a bug in the code. See this comprehensive answer [How can I pass a list as a command-line argument with argparse?](https://stackoverflow.com/a/15753721/8106583) – wuerfelfreak Feb 19 '21 at 18:51
-
@wuerfelfreak Here's the repository: github.com/vbelz/Speech-enhancement. I am working on the 'prediction' part of this project. – AdGo Feb 19 '21 at 20:22
-
Try changing the code to `parser.add_argument('--audio', default=['default_audio.wav'], nargs='+')`. This indeed looks like a bug in the software that needs to be fixed. I see that you have already opened an issue on Github. – wuerfelfreak Feb 20 '21 at 15:07
-
@wuerfelfreak Oh wow! It worked! I CANNOT thank you enough for this. ^_^ – AdGo Feb 20 '21 at 17:27