forked from espnet/espnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_make_pair_json_py.bats
executable file
·112 lines (104 loc) · 2.55 KB
/
test_make_pair_json_py.bats
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env bats
# Copyright 2020 Nagoya University (Wen-Chin Huang)
setup() {
export LC_ALL="en_US.UTF-8"
utils=$(cd $BATS_TEST_DIRNAME/..; pwd)/utils
tmpdir=$(mktemp -d testXXXXXX)
cat << EOF > $tmpdir/test1.json
{
"utts": {
"srcspk_uttid1": {
"input": [
{
"feat": "aaa.ark:123",
"name": "input1",
"shape": [
100,
80
]
}
],
"output": [
{
"name": "target1",
"shape": [
10,
100
],
"text": "these quick.",
"token": "t h e s e <space> q u i c k .",
"tokenid": "1 1 1 1 1 1 1 1 1 1"
}
],
"utt2spk": "srcspk"
}
}
}
EOF
cat << EOF > $tmpdir/test2.json
{
"utts": {
"trgspk_uttid1": {
"input": [
{
"feat": "bbb.ark:123",
"name": "input1",
"shape": [
200,
80
]
}
],
"output": [
{
"name": "target1",
"shape": [
10,
100
],
"text": "these quick.",
"token": "t h e s e <space> q u i c k .",
"tokenid": "1 1 1 1 1 1 1 1 1 1"
}
],
"utt2spk": "trgspk"
}
}
}
EOF
cat << EOF > $tmpdir/valid
{
"utts": {
"uttid1": {
"input": [
{
"feat": "aaa.ark:123",
"name": "input1",
"shape": [
100,
80
]
}
],
"output": [
{
"feat": "bbb.ark:123",
"name": "input1",
"shape": [
200,
80
]
}
]
}
}
}
EOF
}
teardown() {
rm -rf $tmpdir
}
@test "make_pair_json.py" {
python $utils/make_pair_json.py --src-json $tmpdir/test1.json --trg-json $tmpdir/test2.json > $tmpdir/out.json
jsondiff $tmpdir/out.json $tmpdir/valid
}