ZiyuG commited on
Commit
33f5e20
1 Parent(s): 3455f06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -45,14 +45,15 @@ def get_video_url(option):
45
  return videos[option]
46
 
47
  def evaluate_sign_language(user_video, standard_video_option):
48
- new_path = "tmp/user.mp4"
 
49
  # 将文件从临时路径复制到新路径
50
  shutil.copy(user_video, new_path)
51
- shutil.copy(videos[standard_video_option], "tmp/standard.mp4")
52
- shutil.copy(jsons[standard_video_option], "tmp/standard.json") #comment if produce standard json files
53
  ######
54
  test, standard = user_video, videos[standard_video_option]
55
- score, final_merged_intervals, comments = eval(test, standard)
56
  # return None # comment if NOT produce standard json files
57
 
58
  if score < 95:
@@ -97,7 +98,7 @@ def evaluate_sign_language(user_video, standard_video_option):
97
  advice += "<br>建議:請參考標準視頻,模仿正確的動作,保持速度一致。<br><br>"
98
  advice += f"<b>綜合評分:</b> 您本次的總評分為 {score:.2f}/100分。<br>"
99
 
100
- ret_video = gen_audio(subtitles)
101
  return advice, ret_video
102
 
103
  font = ["Heiti SC", "FangSong"]
 
45
  return videos[option]
46
 
47
  def evaluate_sign_language(user_video, standard_video_option):
48
+ tmpdir = tempfile.TemporaryDirectory()
49
+ new_path = tmpdir + "/user.mp4"
50
  # 将文件从临时路径复制到新路径
51
  shutil.copy(user_video, new_path)
52
+ shutil.copy(videos[standard_video_option], tmpdir + "/standard.mp4")
53
+ shutil.copy(jsons[standard_video_option], tmpdir + "/standard.json") #comment if produce standard json files
54
  ######
55
  test, standard = user_video, videos[standard_video_option]
56
+ score, final_merged_intervals, comments = eval(test, standard, tmpdir)
57
  # return None # comment if NOT produce standard json files
58
 
59
  if score < 95:
 
98
  advice += "<br>建議:請參考標準視頻,模仿正確的動作,保持速度一致。<br><br>"
99
  advice += f"<b>綜合評分:</b> 您本次的總評分為 {score:.2f}/100分。<br>"
100
 
101
+ ret_video = gen_audio(subtitles, tmpdir)
102
  return advice, ret_video
103
 
104
  font = ["Heiti SC", "FangSong"]