Ejemplo n.º 1
0
 def classify(self, file):
     """
     classify given audio file as one of given classes
     @param file: audio file object
     @return: result of classification
     """
     result = {}
     current_characteristics = vad(file, frame_size=self.frame_size)
     for i in self.used_classes:
         result[i] = {}
         for j in self.used_characteristics:
             result[i][j] = self.probability(i, j, current_characteristics.get(j))
     return result
Ejemplo n.º 2
0
 def teach_one_class(self, class_key):
     """
     1. method runs VAD for each file which is not classified yet
     2. gets all needle characteristics which were set in init method
     3. runs teach method for each of characteristics
     @param class_key: name of active class of data
     """
     words_count = 0
     characteristics = self.data_class[class_key]
     for i in self.audio_files[class_key]:
         if not i.classified:
             parameters = vad(i.file_object, frame_size=self.frame_size)
             for j in self.used_characteristics:
                 self.teach(parameters.get(j), characteristics[j])
             words_count += parameters.get("words_count")
             i.classified = True
     self.words_count[class_key] += words_count