Spaces:
Runtime error
Runtime error
| from fastapi import FastAPI, Query | |
| from fastapi.responses import StreamingResponse | |
| import io | |
| import numpy as np | |
| import soundfile as sf | |
| from inference import load_model, synthesize | |
| app = FastAPI() | |
| async def startup_event(): | |
| load_model() | |
| async def voice(text: str = Query(..., description="Text to synthesize")): | |
| audio = synthesize(text) | |
| buf = io.BytesIO() | |
| sf.write(buf, audio, 24000, format="WAV") | |
| buf.seek(0) | |
| return StreamingResponse(buf, media_type="audio/wav") | |