Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -1,6 +1,7 @@ | |||
| 1 | #! /usr/bin/env python | 1 | #! /usr/bin/env python |
| 2 | 2 | ||
| 3 | import os | 3 | import os |
| 4 | import re | ||
| 4 | import glob | 5 | import glob |
| 5 | import numpy as np | 6 | import numpy as np |
| 6 | from tempfile import mkstemp | 7 | from tempfile import mkstemp |
| @@ -77,3 +78,16 @@ def count_files_in_directory(samples_dir): · 70 unmodified lines | |||
| 77 | if file_path: | 78 | if file_path: |
| 78 | total_files += 1 | 79 | total_files += 1 |
| 79 | return total_files | 80 | return total_files |
| 81 | |||
| 82 | def parse_file_samplerate(soundfile): | ||
| 83 | samplerate = None | ||
| 84 | # parse samplerate | ||
| 85 | re_sr = re.compile(r'/([0-9]{4,})Hz_.*') | ||
| 86 | match_samplerate = re_sr.findall(soundfile) | ||
| 87 | if match_samplerate: | ||
| 88 | samplerate = int(match_samplerate[0]) | ||
| 89 | else: | ||
| 90 | import warnings | ||
| 91 | warnings.warn(UserWarning("could not parse samplerate for {:s}" | ||
| 92 | .format(soundfile))) | ||
| 93 | return samplerate | ||