Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import array
import struct
def float_to_16_bit_pcm(raw_floats):
floats = array.array('f', raw_floats)
samples = [sample * 32767 for sample in floats]
raw_ints = struct.pack("<%dh" % len(samples), *samples)
return raw_ints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment