6 from tempfile import mkstemp
8 def array_from_text_file(filename, dtype = 'float'):
9 filename = os.path.join(os.path.dirname(__file__), filename)
10 with open(filename) as f:
12 return np.array([line.split() for line in lines],
15 def list_all_sounds(rel_dir):
16 datadir = os.path.join(os.path.dirname(__file__), rel_dir)
17 return glob.glob(os.path.join(datadir,'*.*'))
19 def get_default_test_sound(TestCase, rel_dir = 'sounds'):
20 all_sounds = list_all_sounds(rel_dir)
21 if len(all_sounds) == 0:
22 TestCase.skipTest("please add some sounds in \'python/tests/sounds\'")
26 def get_tmp_sink_path():
31 def del_tmp_sink_path(path):
34 def array_from_yaml_file(filename):
37 yaml_data = yaml.safe_load(f)
41 def count_samples_in_file(file_path):
42 from aubio import source
44 s = source(file_path, 0, hopsize)
49 if read < hopsize: break
52 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):
64 for f in os.walk(samples_dir):
67 file_path = os.path.join(f[0], each)