Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- .huggingface/README.md +1 -0
- Dockerfile +10 -0
- app.py +15 -0
- requirements.txt +5 -0
.huggingface/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
This is a Bark API for text-to-speech conversion.
|
Dockerfile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
COPY requirements.txt .
|
| 6 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 7 |
+
|
| 8 |
+
COPY . .
|
| 9 |
+
|
| 10 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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("suno/bark-small", 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()}
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi==0.99.1
|
| 2 |
+
uvicorn[standard]
|
| 3 |
+
transformers
|
| 4 |
+
huggingface_hub
|
| 5 |
+
torch
|