3 def array_from_text_file(filename, dtype = 'float'):
5 from numpy import array
6 filename = os.path.join(os.path.dirname(__file__), filename)
7 return array([line.split() for line in open(filename).readlines()],
10 def list_all_sounds(rel_dir):
12 datadir = os.path.join(os.path.dirname(__file__), rel_dir)
13 return glob.glob(os.path.join(datadir,'*.*'))
15 def array_from_yaml_file(filename):
18 yaml_data = yaml.safe_load(f)
22 def count_samples_in_file(file_path):
23 from aubio import source
25 s = source(file_path, 0, hopsize)
30 if read < hopsize: break
33 def count_samples_in_directory(samples_dir):
36 for f in os.walk(samples_dir):
39 file_path = os.path.join(f[0], each)
41 total_frames += count_samples_in_file(file_path)