File size: 452 Bytes
1ee91f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
from inference import synthesize_voice, load_model
import io

app = FastAPI()

# πŸ›  ァーバ衷動時にヒデルをロードする
@app.on_event("startup")
async def startup_event():
    load_model()

@app.get("/voice")
async def voice_endpoint(text: str):
    wav_bytes = synthesize_voice(text)
    return StreamingResponse(io.BytesIO(wav_bytes), media_type="audio/wav")