Spaces:
Sleeping
Sleeping
Yarik
commited on
Commit
·
e5f531d
1
Parent(s):
e268677
update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,34 @@
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import sys
|
3 |
-
import time
|
4 |
-
import threading
|
5 |
import tempfile
|
6 |
-
import
|
7 |
-
import
|
8 |
-
|
|
|
|
|
9 |
from fastapi.responses import FileResponse, JSONResponse
|
10 |
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
|
11 |
-
from pydantic import BaseModel
|
12 |
from huggingface_hub import hf_hub_download
|
|
|
|
|
13 |
from torch import no_grad, package
|
14 |
-
|
15 |
from accentor import accentification, stress_replace_and_shift
|
16 |
-
import argparse
|
17 |
-
from passlib.context import CryptContext
|
18 |
|
19 |
app = FastAPI(docs_url=None, redoc_url=None)
|
20 |
|
21 |
# Set environment variable for Hugging Face cache directory
|
22 |
os.environ["HF_HOME"] = "/app/.cache"
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
tts_kwargs = {
|
25 |
"speaker_name": "uk",
|
26 |
"language_name": "uk",
|
@@ -88,7 +96,7 @@ def trim_memory():
|
|
88 |
|
89 |
def init_models():
|
90 |
models = {}
|
91 |
-
model_path = hf_hub_download("theodotus/tts-vits-lada-uk", "model.pt")
|
92 |
importer = package.PackageImporter(model_path)
|
93 |
models["lada"] = importer.load_pickle("tts_models", "model")
|
94 |
return models
|
|
|
1 |
+
import argparse
|
2 |
+
import ctypes
|
3 |
+
import gc
|
4 |
import os
|
5 |
import sys
|
|
|
|
|
6 |
import tempfile
|
7 |
+
import threading
|
8 |
+
import time
|
9 |
+
|
10 |
+
import uvicorn
|
11 |
+
from fastapi import FastAPI, Depends, HTTPException
|
12 |
from fastapi.responses import FileResponse, JSONResponse
|
13 |
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
|
|
|
14 |
from huggingface_hub import hf_hub_download
|
15 |
+
from passlib.context import CryptContext
|
16 |
+
from pydantic import BaseModel
|
17 |
from torch import no_grad, package
|
18 |
+
|
19 |
from accentor import accentification, stress_replace_and_shift
|
|
|
|
|
20 |
|
21 |
app = FastAPI(docs_url=None, redoc_url=None)
|
22 |
|
23 |
# Set environment variable for Hugging Face cache directory
|
24 |
os.environ["HF_HOME"] = "/app/.cache"
|
25 |
|
26 |
+
os.environ["STANZA_RESOURCES_DIR"] = "/app/stanza_resources"
|
27 |
+
|
28 |
+
# Create necessary directories if they don't exist
|
29 |
+
os.makedirs("/app/stanza_resources", exist_ok=True)
|
30 |
+
os.makedirs("/app/model", exist_ok=True)
|
31 |
+
|
32 |
tts_kwargs = {
|
33 |
"speaker_name": "uk",
|
34 |
"language_name": "uk",
|
|
|
96 |
|
97 |
def init_models():
|
98 |
models = {}
|
99 |
+
model_path = hf_hub_download("theodotus/tts-vits-lada-uk", "model.pt", cache_dir="/app/model")
|
100 |
importer = package.PackageImporter(model_path)
|
101 |
models["lada"] = importer.load_pickle("tts_models", "model")
|
102 |
return models
|