# cat blog >> /dev/brain 2> /proc/mind
cat blog >> /dev/brain 2> /proc/mind
# cat starbyte.py from PIL import Image, ImageDraw import scipy.io.wavfile import sys import wave inputfile = sys.argv[1] wave_read_object = wave.open(inputfile, 'rb') print 'Number of audio channels = ', wave_read_object.getnchannels() print 'Sample width = ', wave_read_object.getsampwidth(), '(bytes)' print 'Sampling frequency = ', wave_read_object.getframerate(), '(Hz)' frames = wave_read_object.getnframes() print 'Number of audio frames = ', frames wave_read_object.close() rate, data = scipy.io.wavfile.read(inputfile) last_frame = -1 c = '' r = '' i = 0 for frame in data: if frame > 90: if last_frame != 1: c += '1' i += 1 last_frame = 1 elif frame > 23: if last_frame != 0: c += '0' i += 1 last_frame = 0 else: last_frame = -1 if i == 10: nc = '' for j in c: nc = j + nc r += chr(int(nc, 2)) c = '' i = 0 r = r.split('\n') image = Image.new('RGB', (1000, 1000), 'black') draw = ImageDraw.Draw(image) for line in r: line = line.split() if 'LINE' in line: x1, y1, x2, y2 = map(int, line[1:]) draw.line([(x1, y1), (x2, y2)], 'green') #elif 'REKT' in line: # x1, y1, x2, y2 = map(int, line[1:]) # draw.rectangle([(x1, y1), (x2, y2)], None, 'green') elif 'CRCL' in line: x1, y1, rad = map(int, line[1:]) draw.arc([(x1 - rad, y1 - rad), (x1 + rad, y1 + rad)], 0, 360, 'green') image.save('image.png') # python starbyte.py starbyte.wav Number of audio channels = 1 Sample width = 1 (bytes) Sampling frequency = 44100 (Hz) Number of audio frames = 3885808 # eog image.png
cat starbyte.py
python starbyte.py starbyte.wav
eog image.png
Post a Comment
No comments:
Post a Comment