Ellie5757575757 commited on
Commit
af07bc1
·
verified ·
1 Parent(s): e87c252

Update pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +8 -14
pipeline.py CHANGED
@@ -1,20 +1,14 @@
 
1
  from utils_audio import convert_to_wav
2
  from to_cha import to_cha_from_wav
3
- from cha_json import cha_to_json_path
4
- from model_infer import AphasiaClassifier
5
- from output import format_result
 
6
 
7
  def run_pipeline(in_media_path: str, out_style: str = "json") -> str:
8
  wav = convert_to_wav(in_media_path, sr=16000, mono=True)
9
  cha = to_cha_from_wav(wav, lang="eng")
10
- jsn = cha_to_json_path(cha)
11
-
12
- clf = AphasiaClassifier()
13
- pred = clf.predict_from_json(jsn)
14
-
15
- return format_result(pred, style=out_style)
16
-
17
- if __name__ == "__main__":
18
- import sys
19
- media = sys.argv[1]
20
- print(run_pipeline(media, out_style="text")) # or "json"
 
1
+ import json
2
  from utils_audio import convert_to_wav
3
  from to_cha import to_cha_from_wav
4
+ from cha_json import cha_to_json_file
5
+ from output import predict_from_chajson
6
+
7
+ MODEL_DIR = "./adaptive_aphasia_model"
8
 
9
  def run_pipeline(in_media_path: str, out_style: str = "json") -> str:
10
  wav = convert_to_wav(in_media_path, sr=16000, mono=True)
11
  cha = to_cha_from_wav(wav, lang="eng")
12
+ chajson_path, _ = cha_to_json_file(cha)
13
+ results = predict_from_chajson(MODEL_DIR, chajson_path, output_file=None)
14
+ return json.dumps(results, ensure_ascii=False, indent=2)