ankban commited on
Commit
e3e16dc
·
verified ·
1 Parent(s): 35002f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -6,6 +6,7 @@ from gtts import gTTS
6
  import subprocess
7
  import openai
8
  from openai import OpenAI
 
9
 
10
  # Use writable cache for Hugging Face
11
  os.environ["MPLCONFIGDIR"] = "/tmp/matplotlib"
@@ -19,6 +20,20 @@ chatter_owl_url = "file/images/chatter_owl.png"
19
  model = WhisperModel("base", compute_type="int8") # Fastest CPU option
20
  openai.api_key = os.getenv("OPENAI_API_KEY")
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  # Prompt template
23
  PROMPT_TEMPLATE = """
24
  You are a communication coach evaluating a user's spoken response.
 
6
  import subprocess
7
  import openai
8
  from openai import OpenAI
9
+ import shutil
10
 
11
  # Use writable cache for Hugging Face
12
  os.environ["MPLCONFIGDIR"] = "/tmp/matplotlib"
 
20
  model = WhisperModel("base", compute_type="int8") # Fastest CPU option
21
  openai.api_key = os.getenv("OPENAI_API_KEY")
22
 
23
+ # Optional safety check
24
+ TMP_DIR = "/tmp"
25
+
26
+ # Clean up /tmp folder at runtime start
27
+ for sub in os.listdir(TMP_DIR):
28
+ sub_path = os.path.join(TMP_DIR, sub)
29
+ try:
30
+ if os.path.isfile(sub_path) or os.path.islink(sub_path):
31
+ os.unlink(sub_path)
32
+ elif os.path.isdir(sub_path):
33
+ shutil.rmtree(sub_path)
34
+ except Exception as e:
35
+ print(f"Failed to delete {sub_path}. Reason: {e}")
36
+
37
  # Prompt template
38
  PROMPT_TEMPLATE = """
39
  You are a communication coach evaluating a user's spoken response.