Changeset 0b6d23d for python/tests/utils.py
- Timestamp:
- May 16, 2016, 5:08:18 AM (8 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- a6f9ebf
- Parents:
- 58a5fb9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/tests/utils.py
r58a5fb9 r0b6d23d 1 1 #! /usr/bin/env python 2 2 3 import os 4 import glob 5 import numpy as np 6 from tempfile import mkstemp 7 3 8 def array_from_text_file(filename, dtype = 'float'): 4 import os.path5 from numpy import array6 9 filename = os.path.join(os.path.dirname(__file__), filename) 7 10 with open(filename) as f: 8 11 lines = f.readlines() 9 return array([line.split() for line in lines],12 return np.array([line.split() for line in lines], 10 13 dtype = dtype) 11 14 12 15 def list_all_sounds(rel_dir): 13 import os.path, glob14 16 datadir = os.path.join(os.path.dirname(__file__), rel_dir) 15 17 return glob.glob(os.path.join(datadir,'*.*')) … … 23 25 24 26 def get_tmp_sink_path(): 25 from tempfile import mkstemp26 import os27 27 fd, path = mkstemp() 28 28 os.close(fd) … … 30 30 31 31 def del_tmp_sink_path(path): 32 import os33 32 os.unlink(path) 34 33 … … 46 45 total_frames = 0 47 46 while True: 48 samples, read = s()47 _, read = s() 49 48 total_frames += read 50 49 if read < hopsize: break … … 52 51 53 52 def count_samples_in_directory(samples_dir): 54 import os55 53 total_frames = 0 56 54 for f in os.walk(samples_dir): … … 63 61 64 62 def count_files_in_directory(samples_dir): 65 import os66 63 total_files = 0 67 64 for f in os.walk(samples_dir):
Note: See TracChangeset
for help on using the changeset viewer.