Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python
import sys
import os
import numpy as np
if not len(sys.argv) == 3:
print('Incorrect # of arguments')
sample_file = sys.argv[1]
sample_rate = int(sys.argv[2])
print('Using sample rate of {} Hz'.format(sample_rate))
samples = []
with open(sample_file, 'r') as soundfile:
for line in soundfile.readlines()[1:]:
time, _, mosi, miso = line.split(',')
sample = int(miso, 16)
sound_filename = '{}.wav'.format(os.path.splitext(os.path.basename(sample_file))[0]), sample_rate, np.array(samples, dtype=np.uint8))
print('Generated {}'.format(sound_filename))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment