blacknight3113 commited on
Commit
7ceebd8
·
verified ·
1 Parent(s): 253c93e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
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
- # Télécharge dynamiquement ton modèle Bark depuis ton Model Repo
8
- model_dir = snapshot_download("blacknight3113/bark-api", repo_type="model")
 
 
 
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 {"sampling_rate": out["sampling_rate"], "audio": out["audio"].tolist()}
 
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()}