def parse_sph_header( fh ):
    """Read the file-format header for an sph file
    
    The SPH header-file is exactly 1024 bytes at the head of the file,
    there is a simple textual format which AFAIK is always ASCII, but 
    we allow here for latin1 encoding.  The format has a type declaration
    for each field and we only pay attention to fields for which we 
    have some understanding.
    
    returns dictionary describing the format such as::
    
        {
            'sample_rate':8000, 
            'channel_count':1, 
            'sample_byte_format': '01', # little-endian
            'sample_n_bytes':2, 
            'sample_sig_bits': 16, 
            'sample_coding': 'pcm', 
        }
    """
    file_format = {
        'sample_rate':8000, 
        'channel_count':1, 
        'sample_byte_format': '01', # little-endian
        'sample_n_bytes':2, 
        'sample_sig_bits': 16, 
        'sample_coding': 'pcm', 
    }
    end = b'end_head'
    for line in fh.read(1024).splitlines():
        if line.startswith(end):
            break 
        line = line.decode('latin-1')
        for key in file_format.keys():
            if line.startswith(key):
                _, format, value = line.split(None, 3)
                if format == '-i':
                    value = int(value, 10)
                file_format[key] = value 
    return file_format