Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,18 @@
|
|
| 1 |
-
from fastapi import FastAPI, HTTPException
|
| 2 |
from fastapi.responses import FileResponse
|
| 3 |
from kokoro import KPipeline
|
| 4 |
import soundfile as sf
|
| 5 |
import os
|
| 6 |
import tempfile
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
app = FastAPI(title="Text-to-Speech Converter")
|
| 9 |
|
| 10 |
-
# Initialize pipeline
|
| 11 |
pipeline = KPipeline(lang_code='a')
|
| 12 |
|
| 13 |
@app.post("/generate_audio/")
|
|
|
|
| 1 |
+
from fastapi import FastAPI, HTTPException
|
| 2 |
from fastapi.responses import FileResponse
|
| 3 |
from kokoro import KPipeline
|
| 4 |
import soundfile as sf
|
| 5 |
import os
|
| 6 |
import tempfile
|
| 7 |
|
| 8 |
+
# Configure cache directories before initializing pipeline
|
| 9 |
+
os.environ["TRANSFORMERS_CACHE"] = "/app/cache"
|
| 10 |
+
os.environ["HF_HOME"] = "/app/cache"
|
| 11 |
+
os.environ["XDG_CACHE_HOME"] = "/app/cache"
|
| 12 |
+
|
| 13 |
app = FastAPI(title="Text-to-Speech Converter")
|
| 14 |
|
| 15 |
+
# Initialize pipeline with explicit cache settings
|
| 16 |
pipeline = KPipeline(lang_code='a')
|
| 17 |
|
| 18 |
@app.post("/generate_audio/")
|