当前位置: 首页>>代码示例>>Python>>正文


Python Extractor.get_rolloff_moy方法代码示例

本文整理汇总了Python中extractor.Extractor.get_rolloff_moy方法的典型用法代码示例。如果您正苦于以下问题:Python Extractor.get_rolloff_moy方法的具体用法?Python Extractor.get_rolloff_moy怎么用?Python Extractor.get_rolloff_moy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在extractor.Extractor的用法示例。


在下文中一共展示了Extractor.get_rolloff_moy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from extractor import Extractor [as 别名]
# 或者: from extractor.Extractor import get_rolloff_moy [as 别名]
class Teacher:
    def __init__(self):
        self.model = SongModel()
        self.extractor = Extractor()

    def parse_set(self):
        content = []
        with open("training/Tracks/ground_truth.csv") as f:
            for l in f:
                l = l.replace('\"', '').replace('\n', '')
                name = ""
                genre = ""
                flag = 0
                for c in l:
                    if c == ',':
                        flag = 1
                    elif flag == 0:
                        name += c
                    elif flag == 1:
                        genre += c
                content.append([name, genre])
        return content

    def train(self):
        for item in self.parse_set():
            self.extractor.set_song(item[0])
            tempo = self.extractor.get_tempo()
            rolloffmoy = self.extractor.get_rolloff_moy()
            rolloffect = self.extractor.get_rolloff_ect()
            zcrmoy = self.extractor.get_zcr_moy()
            zcrect = self.extractor.get_zcr_ect()
            duration = self.extractor.get_duration()
            self.model.add(item[0], item[1], tempo, rolloffmoy, rolloffect, zcrmoy, zcrect, duration)
            print("ADDED : " + item[0] + " " + item[1] + " " + str(tempo) + " " + str(rolloffmoy) + " " + str(rolloffect) + " " + str(zcrmoy) + " " + str(zcrect) + " " + str(duration))
        print("DONE")
开发者ID:yrakcaz,项目名称:music-style-classifier,代码行数:37,代码来源:teacher.py

示例2: __init__

# 需要导入模块: from extractor import Extractor [as 别名]
# 或者: from extractor.Extractor import get_rolloff_moy [as 别名]
class AI:
    def __init__(self, song):
        self.song = song
        self.model = SongModel()
        self.extractor = Extractor()
        self.tempo = 0
        self.rolloffmoy = 0.0
        self.rolloffect = 0.0
        self.zcrmoy = 0.0
        self.zcrect = 0.0
        self.duration = 0.0
        self.genre = []
        for l in open("training/Tracks/genres.txt"):
            self.genre.append(l.replace('\n',''))

    def get_song_datas(self):
        self.extractor.set_song(self.song)
        self.tempo = self.extractor.get_tempo()
        self.rolloffmoy = self.extractor.get_rolloff_moy()
        self.rolloffect = self.extractor.get_rolloff_ect()
        self.zcrmoy = self.extractor.get_zcr_moy()
        self.zcrect = self.extractor.get_zcr_ect()
        self.duration = self.extractor.get_duration()

    def classify_with_knn(self):
        vect, mat = self.model.get_datas()
        clf = neighbors.KNeighborsClassifier()
        clf.fit(mat, vect)
        self.get_song_datas()
        l = [[self.tempo, self.rolloffmoy, self.rolloffect, self.zcrmoy, self.zcrect, self.duration]]
        ret = clf.predict(l)
        print(self.genre[ret[0]])

    def classify_with_svm(self):
        vect, mat = self.model.get_datas()
        clf = svm.SVC(class_weight='auto', kernel='linear')
        clf.fit(mat, vect)
        self.get_song_datas()
        l = [[self.tempo, self.rolloffmoy, self.rolloffect, self.zcrmoy, self.zcrect, self.duration]]
        ret = clf.predict(l)
        print(self.genre[int(ret[0])])
开发者ID:yrakcaz,项目名称:music-style-classifier,代码行数:43,代码来源:ai.py


注:本文中的extractor.Extractor.get_rolloff_moy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。