ChuxiJ commited on
Commit
25f8a0c
·
1 Parent(s): 628f1e5

feat: change _path_to_audio_url

Browse files
Files changed (1) hide show
  1. acestep/api_server.py +2 -6
acestep/api_server.py CHANGED
@@ -276,18 +276,14 @@ def create_app() -> FastAPI:
276
  INITIAL_AVG_JOB_SECONDS = float(os.getenv("ACESTEP_AVG_JOB_SECONDS", "5.0"))
277
  AVG_WINDOW = int(os.getenv("ACESTEP_AVG_WINDOW", "50"))
278
 
279
- # 服务器配置,用于生成音频下载 URL
280
- SERVER_HOST = os.getenv("ACESTEP_API_HOST", "127.0.0.1")
281
- SERVER_PORT = int(os.getenv("ACESTEP_API_PORT", "8001"))
282
-
283
  def _path_to_audio_url(path: str) -> str:
284
- """将本地文件路径转换为可下载的 HTTP URL"""
285
  if not path:
286
  return path
287
  if path.startswith("http://") or path.startswith("https://"):
288
  return path
289
  encoded_path = urllib.parse.quote(path, safe="")
290
- return f"http://{SERVER_HOST}:{SERVER_PORT}/v1/audio?path={encoded_path}"
291
 
292
  @asynccontextmanager
293
  async def lifespan(app: FastAPI):
 
276
  INITIAL_AVG_JOB_SECONDS = float(os.getenv("ACESTEP_AVG_JOB_SECONDS", "5.0"))
277
  AVG_WINDOW = int(os.getenv("ACESTEP_AVG_WINDOW", "50"))
278
 
 
 
 
 
279
  def _path_to_audio_url(path: str) -> str:
280
+ """将本地文件路径转换为可下载的相对 URL"""
281
  if not path:
282
  return path
283
  if path.startswith("http://") or path.startswith("https://"):
284
  return path
285
  encoded_path = urllib.parse.quote(path, safe="")
286
+ return f"/v1/audio?path={encoded_path}"
287
 
288
  @asynccontextmanager
289
  async def lifespan(app: FastAPI):