Spaces:
Sleeping
Sleeping
Update app/main.py
Browse files- app/main.py +26 -1
app/main.py
CHANGED
|
@@ -1,7 +1,32 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
app = FastAPI()
|
| 4 |
|
|
|
|
| 5 |
@app.get("/")
|
| 6 |
def read_root():
|
| 7 |
return {"message": "Hello from FastAPI on Hugging Face Spaces 🚀"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Response
|
| 2 |
+
import asyncio
|
| 3 |
+
from tts_with_rvc import TTS_RVC
|
| 4 |
+
|
| 5 |
|
| 6 |
app = FastAPI()
|
| 7 |
|
| 8 |
+
|
| 9 |
@app.get("/")
|
| 10 |
def read_root():
|
| 11 |
return {"message": "Hello from FastAPI on Hugging Face Spaces 🚀"}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
@app.post("/speak")
|
| 15 |
+
async def synthesize(text: str):
|
| 16 |
+
tts = TTS_RVC(
|
| 17 |
+
model_path="models/chu2.pth",
|
| 18 |
+
voice="ja-JP-NanamiNeural",
|
| 19 |
+
device="cpu",
|
| 20 |
+
index_path="models/chu.index",
|
| 21 |
+
f0_method="pm"
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
path = tts(
|
| 25 |
+
text=text,
|
| 26 |
+
pitch=6,
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
with open(path, "rb") as f:
|
| 30 |
+
audio_bytes = f.read()
|
| 31 |
+
|
| 32 |
+
return Response(content=audio_bytes, media_type="audio/wav")
|