Zoe0122 commited on
Commit
4446a50
·
verified ·
1 Parent(s): eacd878

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -0
app.py CHANGED
@@ -7,6 +7,7 @@ from deep_translator import GoogleTranslator
7
 
8
  def translate_document(file, target_language, target_country, api_key):
9
  log_messages = []
 
10
 
11
  try:
12
  log_messages.append("Starting translation process...")
@@ -61,6 +62,10 @@ def translate_document(file, target_language, target_country, api_key):
61
  prs.save(output_path)
62
  log_messages.append(f"Saved translated presentation as {output_path}.")
63
 
 
 
 
 
64
  return output_path, "\n".join(log_messages) # 返回文件路徑和日誌信息
65
 
66
  except Exception as e:
 
7
 
8
  def translate_document(file, target_language, target_country, api_key):
9
  log_messages = []
10
+ output_path = None # 初始化 output_path
11
 
12
  try:
13
  log_messages.append("Starting translation process...")
 
62
  prs.save(output_path)
63
  log_messages.append(f"Saved translated presentation as {output_path}.")
64
 
65
+ else:
66
+ log_messages.append("Unsupported file type. Please upload a .docx or .pptx file.")
67
+ return None, "\n".join(log_messages) # 返回 None 如果文件類型不支持
68
+
69
  return output_path, "\n".join(log_messages) # 返回文件路徑和日誌信息
70
 
71
  except Exception as e: