File: common.py

package info (click to toggle)
pytorch-audio 2.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,696 kB
  • sloc: python: 61,274; cpp: 10,031; sh: 128; ansic: 70; makefile: 34
file content (25 lines) | stat: -rw-r--r-- 788 bytes parent folder | download | duplicates (2)
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