read and write .wav

This commit is contained in:
Alexander Treml 2025-06-20 00:52:28 +02:00
parent 35d03bc0c6
commit 53a82724ae

View file

@ -41,8 +41,20 @@ def hide(input_file: Union[str, IO[bytes]], message: str, output_file: Union[str
output = wave.open(output_file, "wb") output = wave.open(output_file, "wb")
with wave.open(input_file, "rb") as input: with wave.open(input_file, "rb") as input:
pass nchannels, sampwidth, framerate, nframes, comptype, _ = input.getparams()
# TODO assert comptype == "NONE", "only uncompressed files are supported"
nsamples = nchannels * nframes
# TODO get message bits and check length
output.setnchannels(nchannels)
output.setsampwidth(sampwidth)
output.setframerate(framerate)
# TODO encode message length + message
frames = input.readframes(nframes * nchannels)
output.writeframes(frames)
def reveal(input_file: Union[str, IO[bytes]]): def reveal(input_file: Union[str, IO[bytes]]):