Untitled
unknown
python
4 years ago
697 B
9
Indexable
import os import sox def create_length_statistics(root_path): duration = 0.0 for filepath in os.listdir(root_path): t = os.path.join(root_path, filepath) if os.path.isdir(t): partial_duration = create_length_statistics(t) duration += partial_duration elif '.wav' in t: try: duration += sox.file_info.duration(t) except sox.core.SoxiError: pass except TypeError: pass h = round(duration/3600) min = round((duration/60)-h*60) return [h, min] root_path = "/dih4/dih4_2/hearai/data/xxx/" print(create_length_statistics(root_path))
Editor is loading...