You can use this try/except to get around the IndexError
:
try:
wavefile = sys.argv[1]
except IndexError:
wavfile = 'BeatBoy01.wav'
sr,x = scipy.io.wavfile.read(wavfile)
This effectively sets the default file to BeatBoy01.wav
if no argument is passed to the script. Keep in mind that BeatBoy01.wav
should be in the same directory from where the script is executed for this to work.
For easier argument parsing, have a look at the OptParse
library.