<jupyter_start><jupyter_text>Parse Data<jupyter_code>def input_parser(input_file):
   # handle exception to check if there isn't a file which is corrupted
   try:
      # extraction
      X, sample_rate = librosa.load(input_file, res_type='kaiser_fast') 
      # extract mfcc data
      mfccs = np.mean(librosa.feature.mfcc(y=X, sr=sample_rate, n_mfcc=128).T,axis=0) 
   except Exception as e:
      print("Error encountered while parsing file: ", input_file)
      return None
 
   feature = mfccs.tolist()
    
   return feature

value = input_parser(input_file)
value
arr = np.array(value)
arr2d = np.reshape(arr, (1,128))


from joblib import load
model = load('../models/rf_model.sav')
model.predict(arr2d)
#Probability of each value and order of classes
model.predict_proba(arr2d)
model.classes_
#function
def model_test(input_value):
    model = load('../models/rf_model.sav')
    feature = input_parser(input_file)
    arr = np.array(feature)
    arr2d = np.reshape(arr, (1,128))
    result = model.predict(arr2d)
    
    return result
model_test(value)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11172161172161173, 'fraction_numerical': 0.015567765567765568, 'mean_word_length': 4.013761467889908, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '179465', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 403, 'n_tokens_neox': 381, 'n_words': 86, 'path': 'data_prep/input_parser.ipynb', 'repo_name': 'timsamson/audible_emotion_recognition', 'size': '1092'}