prakashp1893 commited on
Commit
4aab8c8
·
verified ·
1 Parent(s): 9077cd6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -7,16 +7,15 @@ import soundfile as sf
7
  import os
8
  from pydub import AudioSegment
9
 
10
- # --- FIX: Define a local cache directory ---
11
- # This tells transformers to download models here, inside our app's folder,
12
- # instead of the restricted '/.cache' directory.
13
- CACHE_DIR = "/code/cache"
14
  os.makedirs(CACHE_DIR, exist_ok=True)
15
 
16
  # Initialize the FastAPI app
17
  app = FastAPI()
18
 
19
- # --- FIX: Load model and processor using the local cache_dir ---
20
  model_name = "facebook/wav2vec2-lv-60-espeak-cv-ft"
21
  processor = Wav2Vec2Processor.from_pretrained(model_name, cache_dir=CACHE_DIR)
22
  model = Wav2Vec2ForCTC.from_pretrained(model_name, cache_dir=CACHE_DIR)
 
7
  import os
8
  from pydub import AudioSegment
9
 
10
+ # --- FINAL FIX: Use the writable /tmp directory for the cache ---
11
+ # The /code directory is read-only in Hugging Face Spaces. /tmp is writable.
12
+ CACHE_DIR = "/tmp/huggingface-cache"
 
13
  os.makedirs(CACHE_DIR, exist_ok=True)
14
 
15
  # Initialize the FastAPI app
16
  app = FastAPI()
17
 
18
+ # --- FIX: Load model and processor using the correct cache_dir ---
19
  model_name = "facebook/wav2vec2-lv-60-espeak-cv-ft"
20
  processor = Wav2Vec2Processor.from_pretrained(model_name, cache_dir=CACHE_DIR)
21
  model = Wav2Vec2ForCTC.from_pretrained(model_name, cache_dir=CACHE_DIR)