-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodules.py
62 lines (56 loc) · 1.82 KB
/
modules.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 07 06:06:23 2018
author: @aditya
This file contains modules to be used in `audio` as well as `feature` submodules
"""
import os
import yaml
import feature_description as F
def CreateFolder( fd ):
if not os.path.exists(fd):
os.makedirs(fd)
def rem_all_files(folder):
for the_file in os.listdir(folder):
file_path = os.path.join(folder, the_file)
try:
if os.path.isfile(file_path):
os.unlink(file_path)
except Exception as e:
print(e)
def read_yaml(yaml_file):
if not os.path.exists(yaml_file) or not os.path.isfile(yaml_file):
print("No yaml files found!! Try Again.")
return
with open(yaml_file, 'r') as stream:
try:
return yaml.load(stream)
except yaml.YAMLError as exc:
print(exc)
def call_ftr_one(feature_name,featx,wav_file,library):
# Don't put dateset=None on the abv line
"""
Introduce features here
"""
if feature_name == "mel":
X = F.mel(featx,wav_file,library)
elif feature_name == "logmel":
X = F.logmel(featx,wav_file,library)
elif feature_name == "cqt":
X = F.cqt(featx,wav_file,library)
elif feature_name == "spectralcentroid":
X = F.spectralCentroid(featx,wav_file,library)
elif feature_name == "zcr":
X = F.zcr(featx,wav_file,library)
elif feature_name == "stft":
X = F.stft(featx,wav_file,library)
elif feature_name == "istft":
X = F.istft(featx,wav_file,library)
elif feature_name == "spectralrolloff":
X = F.SpectralRolloff(featx,wav_file,library)
else:
X = 1000
return X
def get_list():
features_list=['mel','logmel','cqt','zcr','spectralcentroid','stft','istft','spectralrolloff']
return features_list