from pathlib import Path


def find_feats(directory, utt_id, typ="out_duration", ext="-feats.npy"):
    """Find features for a given utterance.

    Args:
        directory (str): directory to search
        utt_id (str): utterance id
        typ (str, optional): type of the feature. Default: "out_duration"
        ext (str, optional): extension of the feature. Default: "-feats.npy"

    Returns:
        str: path to the feature file
    """
    if isinstance(directory, str):
        directory = Path(directory)
    ps = sorted(directory.rglob(f"**/{typ}/{utt_id}{ext}"))
    return ps[0]