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 get_default_test_sound(TestCase, rel_dir = 'sounds'):
16 all_sounds = list_all_sounds(rel_dir)
17 if len(all_sounds) == 0:
18 TestCase.skipTest("please add some sounds in \'python/tests/sounds\'")
22 def array_from_yaml_file(filename):
25 yaml_data = yaml.safe_load(f)
29 def count_samples_in_file(file_path):
30 from aubio import source
32 s = source(file_path, 0, hopsize)
37 if read < hopsize: break
40 def count_samples_in_directory(samples_dir):
43 for f in os.walk(samples_dir):
46 file_path = os.path.join(f[0], each)
48 total_frames += count_samples_in_file(file_path)
51 def count_files_in_directory(samples_dir):
54 for f in os.walk(samples_dir):
57 file_path = os.path.join(f[0], each)