cigol123 commited on
Commit
58aeb8f
·
verified ·
1 Parent(s): 5e33367

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -5,10 +5,17 @@ import soundfile as sf
5
  import numpy as np
6
  from scipy import signal
7
  import os
 
8
 
9
  # Set the cache directory to a writable location
10
- os.environ["TRANSFORMERS_CACHE"] = "/tmp/.cache"
11
- os.environ["HF_DATASETS_CACHE"] = "/tmp/.cache"
 
 
 
 
 
 
12
 
13
  # Load the Whisper model and processor directly from Hugging Face
14
  def load_model():
 
5
  import numpy as np
6
  from scipy import signal
7
  import os
8
+ import shutil
9
 
10
  # Set the cache directory to a writable location
11
+ cache_dir = "/tmp/.cache"
12
+ os.environ["TRANSFORMERS_CACHE"] = cache_dir
13
+ os.environ["HF_DATASETS_CACHE"] = cache_dir
14
+
15
+ # Clear the cache directory to avoid corruption issues
16
+ if os.path.exists(cache_dir):
17
+ shutil.rmtree(cache_dir)
18
+ os.makedirs(cache_dir, exist_ok=True)
19
 
20
  # Load the Whisper model and processor directly from Hugging Face
21
  def load_model():