diff --git a/api.py b/api.py index 95f90b9..fe64407 100644 --- a/api.py +++ b/api.py @@ -11,6 +11,7 @@ import uvicorn from fastapi import FastAPI, HTTPException, Request from fastapi.responses import StreamingResponse from hypy_utils.logging_utils import setup_logger +from starlette.middleware.cors import CORSMiddleware from torch import no_grad, LongTensor import commons @@ -31,6 +32,15 @@ language_marks = { "Mix": "", } +# Allow all CORS +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + def get_text(text: str, is_symbol: bool): text_norm = text_to_sequence(text, hps.symbols, [] if is_symbol else hps.data.text_cleaners)