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 with open(filename) as f:
9 return array([line.split() for line in lines],
12 def list_all_sounds(rel_dir):
14 datadir = os.path.join(os.path.dirname(__file__), rel_dir)
15 return glob.glob(os.path.join(datadir,'*.*'))
17 def get_default_test_sound(TestCase, rel_dir = 'sounds'):
18 all_sounds = list_all_sounds(rel_dir)
19 if len(all_sounds) == 0:
20 TestCase.skipTest("please add some sounds in \'python/tests/sounds\'")
24 def get_tmp_sink_path():
25 from tempfile import mkstemp
31 def del_tmp_sink_path(path):
35 def array_from_yaml_file(filename):
38 yaml_data = yaml.safe_load(f)
42 def count_samples_in_file(file_path):
43 from aubio import source
45 s = source(file_path, 0, hopsize)
50 if read < hopsize: break
53 def count_samples_in_directory(samples_dir):
56 for f in os.walk(samples_dir):
59 file_path = os.path.join(f[0], each)
61 total_frames += count_samples_in_file(file_path)
64 def count_files_in_directory(samples_dir):
67 for f in os.walk(samples_dir):
70 file_path = os.path.join(f[0], each)