Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,19 @@
|
|
| 1 |
from fastapi import FastAPI, Body
|
| 2 |
from huggingface_hub import snapshot_download
|
| 3 |
from transformers import pipeline
|
|
|
|
| 4 |
|
| 5 |
app = FastAPI()
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
tts = pipeline("text-to-speech", model=model_dir)
|
| 11 |
|
| 12 |
@app.post("/tts")
|
| 13 |
async def tts_api(text: str = Body(..., embed=True)):
|
| 14 |
out = tts(text, forward_params={"do_sample": True})
|
| 15 |
-
return {"
|
|
|
|
| 1 |
from fastapi import FastAPI, Body
|
| 2 |
from huggingface_hub import snapshot_download
|
| 3 |
from transformers import pipeline
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
app = FastAPI()
|
| 7 |
|
| 8 |
+
model_dir = snapshot_download(
|
| 9 |
+
"blacknight3113/bark-api",
|
| 10 |
+
repo_type="model",
|
| 11 |
+
use_auth_token=True # Utilise le token du secret
|
| 12 |
+
)
|
| 13 |
|
| 14 |
tts = pipeline("text-to-speech", model=model_dir)
|
| 15 |
|
| 16 |
@app.post("/tts")
|
| 17 |
async def tts_api(text: str = Body(..., embed=True)):
|
| 18 |
out = tts(text, forward_params={"do_sample": True})
|
| 19 |
+
return {"sr": out["sampling_rate"], "audio": out["audio"].tolist()}
|