mirror of
https://github.com/RVC-Boss/GPT-SoVITS.git
synced 2025-10-07 07:02:57 +08:00
Update api.py
接口api增加跨域功能,方便接入其他应用,避免触发同源策略
This commit is contained in:
parent
0ab0e5390f
commit
93be26afbe
10
api.py
10
api.py
@ -129,6 +129,9 @@ from text.cleaner import clean_text
|
||||
from module.mel_processing import spectrogram_torch
|
||||
from my_utils import load_audio
|
||||
import config as global_config
|
||||
from starlette.middleware.cors import CORSMiddleware #引入 CORS中间件模块
|
||||
#设置允许访问的域名
|
||||
origins = ["*"] #"*",即为所有。
|
||||
|
||||
g_config = global_config.Config()
|
||||
|
||||
@ -490,6 +493,13 @@ def handle(refer_wav_path, prompt_text, prompt_language, text, text_language):
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=origins, #设置允许的origins来源
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"], # 设置允许跨域的http方法,比如 get、post、put等。
|
||||
allow_headers=["*"]) #允许跨域的headers,可以用来鉴别来源等作用。
|
||||
|
||||
#clark新增-----2024-02-21
|
||||
#可在启动后动态修改模型,以此满足同一个api不同的朗读者请求
|
||||
@app.post("/set_model")
|
||||
|
Loading…
x
Reference in New Issue
Block a user