Пример #1
0
def extract(feature_name,wav_fd=None,fe_fd=None,yaml_file='',print_arr=[]):
    """
    This function extracts features from audio.

    Parameters
    ----------
        feature_name : str
            Name of feature to be extracted
        wav_fd : str
            Path to audio files
        fe_fd : str
            Path to feature files
        yaml_file : str
            Path to yaml file
        print_arr : str array, optional
            Description of feature that should be printed 
    """
    # Introduce features here
    if feature_name in M.get_list():
        yaml_load=M.read_yaml(yaml_file)
        try:            
            featx=yaml_load[feature_name]
        except Exception as e:
            print("Make sure you add the {} to the YAML file".format(e))
            raise SystemExit
        x=call_ftr(feature_name,featx,wav_fd,fe_fd,print_arr)
        print("Something wrong happened" if x==1000 else "Feature found")
    else:
        print("Invalid Feature Name")
Пример #2
0
def extract_one(feature_name,
                wav_file,
                yaml_file='',
                library='wavread',
                dataset=None):
    """
    This function extracts features from audio.

    Parameters
    ----------
        feature_name : str
            Name of feature to be extracted
        wav_file : str
            Path to a single audio file
        yaml_file : str
            Path to yaml file
    """
    if feature_name in M.get_list():
        yaml_load = M.read_yaml(yaml_file)
        try:
            featx = yaml_load[feature_name]
        except Exception as e:
            print("Make sure you add the {} to the YAML file".format(e))
            raise SystemExit
        x = M.call_ftr_one(feature_name, featx, wav_file, library, dataset)
        print("Something wrong happened" if type(x) ==
              'int' else "Feature found")
        return x
    else:
        print("Invalid Feature Name")
Пример #3
0
def check_dimension(feature, dimy, yaml_file):
    """
    Args:
      feature: Name of the feature
      dimy: Dimension of the extracted feature
      yaml_file: YAML file from which feature was extracted
    Returns:
      None
    Raises:
      exception if dimensions mismatch
    """
    if feature in ['mel', 'logmel']:
        find = 'n_mels'
    elif feature in ['cqt', 'spectralcentroid']:
        find = 'n_mels'
    if feature in M.get_list():
        yaml_load = M.read_yaml(yaml_file)
    n1 = yaml_load[feature][find][0]
    if n1 != dimy:
        print "Dimension Mismatch. Expected {} Found {}".format(n1, dimy)
        raise SystemExit
    else:
        print "Correct dimension"