23 lines
588 B
Python
23 lines
588 B
Python
import wave
|
|
|
|
wav = wave.open("lesfilLeSduBorddemer.wav", mode='rb')
|
|
frames = wav.getnframes()
|
|
bytes = bytearray(list(wav.readframes(frames)))
|
|
|
|
# Replace each frame_byte with only the value of the LSB
|
|
for i in range(len(bytes)):
|
|
bytes[i] = bytes[i] & 1 # bitmask with 00000001
|
|
|
|
# Byte array to string
|
|
result = ""
|
|
for i in range(0, len(bytes), 8):
|
|
byte_chunk = bytes[i:i+8]
|
|
int_value = int("".join(map(str, byte_chunk)), 2)
|
|
char_value = chr(int_value)
|
|
result += char_value
|
|
|
|
# Remove the trailing '#' characters
|
|
decoded = result.split("##")[0]
|
|
|
|
print(decoded)
|
|
wav.close() |