Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,23 +5,20 @@ import soundfile as sf
|
|
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 |
-
#
|
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
|
21 |
def load_model():
|
22 |
-
print("Loading Whisper model and processor...")
|
23 |
-
processor = WhisperProcessor.from_pretrained("
|
24 |
-
model = WhisperForConditionalGeneration.from_pretrained("
|
25 |
print("✓ Model and processor loaded successfully!")
|
26 |
return processor, model
|
27 |
|
|
|
5 |
import numpy as np
|
6 |
from scipy import signal
|
7 |
import os
|
|
|
8 |
|
9 |
# Set the cache directory to a writable location
|
10 |
cache_dir = "/tmp/.cache"
|
11 |
os.environ["TRANSFORMERS_CACHE"] = cache_dir
|
12 |
os.environ["HF_DATASETS_CACHE"] = cache_dir
|
13 |
|
14 |
+
# Ensure the cache directory exists and is writable
|
|
|
|
|
15 |
os.makedirs(cache_dir, exist_ok=True)
|
16 |
|
17 |
+
# Load the Macedonian-ASR Whisper model and processor
|
18 |
def load_model():
|
19 |
+
print("Loading Macedonian-ASR Whisper model and processor...")
|
20 |
+
processor = WhisperProcessor.from_pretrained("Macedonian-ASR/whisper-large-v3-macedonian-asr")
|
21 |
+
model = WhisperForConditionalGeneration.from_pretrained("Macedonian-ASR/whisper-large-v3-macedonian-asr")
|
22 |
print("✓ Model and processor loaded successfully!")
|
23 |
return processor, model
|
24 |
|