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 get_tmp_sink_path():
23 from tempfile import mkstemp
29 def del_tmp_sink_path(path):
33 def array_from_yaml_file(filename):
36 yaml_data = yaml.safe_load(f)
40 def count_samples_in_file(file_path):
41 from aubio import source
43 s = source(file_path, 0, hopsize)
48 if read < hopsize: break
51 def count_samples_in_directory(samples_dir):
54 for f in os.walk(samples_dir):
57 file_path = os.path.join(f[0], each)
59 total_frames += count_samples_in_file(file_path)
62 def count_files_in_directory(samples_dir):
65 for f in os.walk(samples_dir):
68 file_path = os.path.join(f[0], each)