def create(self, soundfile):
# create a raw output, with a single channel and 4000Hz samples of 8bits
- cmd = ['sox', soundfile.get_format_path('ogg'), '-t', 'raw', '-c', '1', '-r', '4000',
+ sound_filename = soundfile.get_format_path('ogg')
+ if not os.path.exists(sound_filename):
+ sound_filename = soundfile.get_format_path('mp3')
+ if not os.path.exists(sound_filename):
+ return
+ cmd = ['sox', sound_filename, '-t', 'raw', '-c', '1', '-r', '4000',
'-e' 'unsigned-integer', '-b', '8', '-']
wave_array = subprocess.check_output(cmd)
for filename, n_samples in (('waveform.json', 200), ('waveform-500.json', 500)):