forked from pytorch/audio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.py
25 lines (20 loc) · 788 Bytes
/
common.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
import json
from parameterized import param
from torchaudio_unittest.common_utils import get_asset_path
def name_func(func, _, params):
if isinstance(params.args[0], str):
args = "_".join([str(arg) for arg in params.args])
else:
args = "_".join([str(arg) for arg in params.args[0]])
return f"{func.__name__}_{args}"
def load_params(*paths):
params = []
with open(get_asset_path(*paths), "r") as file:
for line in file:
data = json.loads(line)
for effect in data["effects"]:
for i, arg in enumerate(effect):
if arg.startswith("<ASSET_DIR>"):
effect[i] = arg.replace("<ASSET_DIR>", get_asset_path())
params.append(param(data))
return params