admin commited on
Commit
ce3f7c0
·
1 Parent(s): e9ebebe
Files changed (2) hide show
  1. app.py +6 -1
  2. utils.py +5 -10
app.py CHANGED
@@ -17,6 +17,7 @@ from utils import (
17
  TEMP_DIR,
18
  TRANSLATE,
19
  CLASSES,
 
20
  )
21
 
22
 
@@ -94,7 +95,11 @@ def infer(wav_path: str, log_name: str, folder_path=TEMP_DIR):
94
  output: torch.Tensor = model(input)
95
  pred_id = torch.max(output.data, 1)[1]
96
  filename = os.path.basename(wav_path)
97
- result = f"{TRANSLATE[CLASSES[pred_id]]} ({CLASSES[pred_id].capitalize()})"
 
 
 
 
98
 
99
  except Exception as e:
100
  status = f"{e}"
 
17
  TEMP_DIR,
18
  TRANSLATE,
19
  CLASSES,
20
+ EN_US,
21
  )
22
 
23
 
 
95
  output: torch.Tensor = model(input)
96
  pred_id = torch.max(output.data, 1)[1]
97
  filename = os.path.basename(wav_path)
98
+ result = (
99
+ CLASSES[pred_id].capitalize()
100
+ if EN_US
101
+ else f"{TRANSLATE[CLASSES[pred_id]]} ({CLASSES[pred_id].capitalize()})"
102
+ )
103
 
104
  except Exception as e:
105
  status = f"{e}"
utils.py CHANGED
@@ -15,11 +15,6 @@ ZH2EN = {
15
  "中国五声调式识别": "Chinese pentatonic mode recognition",
16
  "建议录音时长保持在 20s 左右": "It is recommended to keep the recording length around 20s.",
17
  "引用": "Cite",
18
- "宫": "Gong",
19
- "商": "Shang",
20
- "角": "Jue",
21
- "徵": "Zhi",
22
- "羽": "Yu",
23
  }
24
 
25
  MODEL_DIR = (
@@ -40,11 +35,11 @@ def _L(zh_txt: str):
40
 
41
 
42
  TRANSLATE = {
43
- "Gong": _L("宫"),
44
- "Shang": _L("商"),
45
- "Jue": _L("角"),
46
- "Zhi": _L("徵"),
47
- "Yu": _L("羽"),
48
  }
49
  CLASSES = list(TRANSLATE.keys())
50
  TEMP_DIR = "./__pycache__/tmp"
 
15
  "中国五声调式识别": "Chinese pentatonic mode recognition",
16
  "建议录音时长保持在 20s 左右": "It is recommended to keep the recording length around 20s.",
17
  "引用": "Cite",
 
 
 
 
 
18
  }
19
 
20
  MODEL_DIR = (
 
35
 
36
 
37
  TRANSLATE = {
38
+ "Gong": "宫",
39
+ "Shang": "商",
40
+ "Jue": "角",
41
+ "Zhi": "徵",
42
+ "Yu": "羽",
43
  }
44
  CLASSES = list(TRANSLATE.keys())
45
  TEMP_DIR = "./__pycache__/tmp"