1919class EmotionRecognizer :
2020 """A class for training, testing and predicting emotions based on
2121 speech's features that are extracted and fed into `sklearn` or `keras` model"""
22- def __init__ (self , model , ** kwargs ):
22+ def __init__ (self , model = None , ** kwargs ):
2323 """
2424 Params:
25- model (sklearn model): the model used to detect emotions.
25+ model (sklearn model): the model used to detect emotions. If `model` is None, then self.determine_best_model()
26+ will be automatically called
2627 emotions (list): list of emotions to be used. Note that these emotions must be available in
2728 RAVDESS_TESS & EMODB Datasets, available nine emotions are the following:
2829 'neutral', 'calm', 'happy', 'sad', 'angry', 'fear', 'disgust', 'ps' ( pleasant surprised ), 'boredom'.
@@ -42,8 +43,6 @@ def __init__(self, model, **kwargs):
4243 Note that when `tess_ravdess`, `emodb` and `custom_db` are set to `False`, `tess_ravdess` will be set to True
4344 automatically.
4445 """
45- # model
46- self .model = model
4746 # emotions
4847 self .emotions = kwargs .get ("emotions" , ["sad" , "neutral" , "happy" ])
4948 # make sure that there are only available emotions
@@ -79,6 +78,12 @@ def __init__(self, model, **kwargs):
7978 self .data_loaded = False
8079 self .model_trained = False
8180
81+ # model
82+ if not model :
83+ self .determine_best_model ()
84+ else :
85+ self .model = model
86+
8287 def _set_metadata_filenames (self ):
8388 """
8489 Protected method to get all CSV (metadata) filenames into two instance attributes:
0 commit comments