""" This generates a 30 minute silent wav, and is capable of responding to Range requests. """ import time import re import struct def create_wav_header(sample_rate, bit_depth, channels, duration): bytes_per_sample = bit_depth / 8 block_align = bytes_per_sample * channels byte_rate = sample_rate * block_align sub_chunk_2_size = duration * byte_rate data = b'' # ChunkID data += b'RIFF' # ChunkSize data += struct.pack(' 0: if not response.writer.flush(): break to_send = b'\x00' * min(bytes_remaining_to_send, sample_rate) bytes_remaining_to_send -= len(to_send) response.writer.write(to_send) # Throttle the stream time.sleep(0.5)