Commit 3412cfde authored by fred's avatar fred

create-sound-waveforms: create waveform from mp3 if ogg doesn't exist

parent 9da11f50
......@@ -48,7 +48,12 @@ class Command(BaseCommand):
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):
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)):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment