import struct


def make_float_wav(samples, sample_rate_hz):
  """Makes a 32-bit float WAV."""
  num_frames, num_channels = samples.shape
  block_align = 4 * num_channels
  data = samples.astype('<f4').tobytes()
  return (
      b'RIFF\x00\x00\x00\x00WAVEfmt \x12\x00\x00\x00\x03\x00'
      + struct.pack('<hIIh', num_channels, sample_rate_hz,
                    block_align * sample_rate_hz, block_align)
      + b' \x00\x00\x00fact\x04\x00\x00\x00'
      + struct.pack('<I', num_frames)
      + b'data' + struct.pack('<I', len(data)) + data)