Spaces:
Running
Running
fix cache directory access degnied issue
Browse files- app/asr_worker.py +7 -0
app/asr_worker.py
CHANGED
@@ -1,8 +1,14 @@
|
|
|
|
1 |
import numpy as np
|
2 |
import sherpa_onnx
|
3 |
import scipy.signal
|
4 |
from opencc import OpenCC
|
5 |
from huggingface_hub import hf_hub_download
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
converter = OpenCC('s2t')
|
8 |
|
@@ -21,6 +27,7 @@ for key, path in FILES.items():
|
|
21 |
LOCAL_PATHS[key] = hf_hub_download(
|
22 |
repo_id=REPO_ID,
|
23 |
filename=path,
|
|
|
24 |
)
|
25 |
|
26 |
# Audio resampling utility
|
|
|
1 |
+
import os
|
2 |
import numpy as np
|
3 |
import sherpa_onnx
|
4 |
import scipy.signal
|
5 |
from opencc import OpenCC
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
+
from pathlib import Path
|
8 |
+
|
9 |
+
# Ensure Hugging Face cache is in a user-writable directory
|
10 |
+
CACHE_DIR = Path(__file__).parent / "hf_cache"
|
11 |
+
os.makedirs(CACHE_DIR, exist_ok=True)
|
12 |
|
13 |
converter = OpenCC('s2t')
|
14 |
|
|
|
27 |
LOCAL_PATHS[key] = hf_hub_download(
|
28 |
repo_id=REPO_ID,
|
29 |
filename=path,
|
30 |
+
cache_dir=str(CACHE_DIR),
|
31 |
)
|
32 |
|
33 |
# Audio resampling utility
|