def generate_fingerprints( self, samples: List[int], Fs=DEFAULT_FS) -> Tuple[List[Tuple[str, int]], float]: f""" Generate the fingerprints for the given sample data (channel). :param samples: list of ints which represents the channel info of the given audio file. :param Fs: sampling rate which defaults to {DEFAULT_FS}. :return: a list of tuples for hash and its corresponding offset, together with the generation time. """ t = time() hashes = fingerprint(samples, Fs=Fs) fingerprint_time = time() - t return hashes, fingerprint_time
def get_file_fingerprints(file_name: str, limit: int, print_output: bool = False): channels, fs, file_hash = decoder.read(file_name, limit) fingerprints = set() channel_amount = len(channels) for channeln, channel in enumerate(channels, start=1): if print_output: print( f"Fingerprinting channel {channeln}/{channel_amount} for {file_name}" ) hashes = fingerprint(channel, Fs=fs) if print_output: print( f"Finished channel {channeln}/{channel_amount} for {file_name}" ) fingerprints |= set(hashes) return fingerprints, file_hash