File: common.py

package info (click to toggle)
pytorch-audio 0.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,512 kB
  • sloc: python: 15,606; cpp: 1,352; sh: 257; makefile: 21
file content (26 lines) | stat: -rw-r--r-- 789 bytes parent folder | download
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
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