Created
November 16, 2018 20:00
-
-
Save redspider/5548fdb1d8e1d8a78ce78ff196aace15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import wave | |
| from itertools import zip_longest | |
| START = 1500 | |
| END = 1500 + 86 * 11 | |
| def grouper(n, iterable, fillvalue=None): | |
| args = [iter(iterable)] * n | |
| return zip_longest(fillvalue=fillvalue, *args) | |
| def sequence_to_bin(s): | |
| s = tuple(s) | |
| if s == (64, 64, 192, 192) * 8: | |
| return ' ' | |
| elif s == (64, 64, 64, 64, 192, 192, 192, 192) * 4: | |
| return 'X' | |
| else: | |
| print(s) | |
| raise Exception() | |
| with wave.open('file.wav', 'r') as wfh: | |
| raw = [n for n in wfh.readframes(wfh.getnframes())] | |
| values = [sequence_to_bin(x) for x in grouper(32, raw)] | |
| lines = list(grouper(11, values[START:END], '.')) | |
| set_a = lines[:43] | |
| set_b = lines[43:] | |
| for a, b in zip_longest(set_a, set_b, fillvalue=['-']): | |
| print(f"{''.join(a)} {''.join(b)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment