Mar-28-2020, 08:04 PM
Hello, I want to be able to read the contents of a .wav file, decode it into a list of ints, analyse it/modify it, and then encode it and save it back as another .wav file. I can load and decode it so far, but I can't figure out how to encode it again. I was thinking something like
int.to_bytes()Here's my code:
#!/usr/bin/env python3 import wave, pyaudio, soundfile filename = 'testfile.wav' file = wave.open(filename, 'rb') c, ss, fr, f, ct, cn = file.getparams() frames = file.readframes(c * ss * f) data = [] for i in range(len(frames)): item = int.from_bytes(frames[i:i + 1], byteorder='little', signed=True) data.append(item)-707