multi_channel_experiment.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:bof-aed 作者: rgrzeszi 项目源码 文件源码
def read_files(self, annotations, channels):
        '''
        Read all files in the datapath and create features_windows dictionary.
        @param annotations: Annotations as read from annotation file
        @param channels: 1D numpy array of channel indices to use.
        @return: A dictionary containing a feature matrix [windows x features] with the classnames as keys
        '''

        if type(channels) == int or type(channels) == np.int64:
            channels = np.array([channels])
        elif type(channels) == list:
            channels = np.array(channels)

        features_frames = {}
        for classname in self.classes:
            features_frames[classname] = []

        features_windows = {}
        for classname in self.classes:
            features_windows[classname] = []

        annotation_dict = defaultdict(list)
        for anno in annotations:
            annotation_dict[anno[3]].append(anno)

        for filename, annos in annotation_dict.items():
            path = self.basepath + '/audio/' + filename
            self._read_windows(path, annos, features_windows, features_frames, channels)

        return features_windows, features_frames
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号