File size: 537 Bytes
0e07c1c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
from fastapi import FastAPI
from pydantic import BaseModel
import app # import the functions from app.py
app_api = FastAPI()
class TextRequest(BaseModel):
text: str
@app_api.post("/synthesize/")
async def synthesize(request: TextRequest):
processed_text = app.preprocess_text(request.text)
synthesized_audio = app.synthesize_speech(processed_text)
return {"processed_text": processed_text, "audio": synthesized_audio}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app_api, host="0.0.0.0", port=8000)
|