-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_sample_rate.py
54 lines (42 loc) · 1.01 KB
/
check_sample_rate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#
# Check the sample rate for all files in a dir
#
import argparse
from os import path
import glob
from utils import check_sample_rate
from config import (
COMPARTMENT_ID,
NAMESPACE,
EXT,
JSON_EXT,
WAV_DIR,
)
def parser_add_args(parser):
parser.add_argument(
"--wav_dir",
type=str,
required=True,
help="Input wav files directory",
)
parser.add_argument(
"--sample_rate",
type=str,
required=True,
help="Expected sample rate (es: 16000)",
)
return parser
parser = argparse.ArgumentParser()
parser = parser_add_args(parser)
args = parser.parse_args()
WAV_DIR = args.wav_dir
SAMPLE_RATE = int(args.sample_rate)
print()
print("Checking the sampling rate of audio files..")
print(f"Expected sample_rate is: {SAMPLE_RATE}")
print()
list_wav = sorted(glob.glob(path.join(WAV_DIR, f"*.{EXT}")))
for f_name in list_wav:
is_ok = check_sample_rate(f_name, SAMPLE_RATE)
print(f"Checking {f_name}, OK: {is_ok}")
print()