Log TTS errors on create
Record exception details during TTS generation to help diagnose 500 errors.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
import logging
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from fastapi import FastAPI, HTTPException, Request
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
@@ -29,6 +31,7 @@ RESOURCES_DIR = ROOT_DIR / "resources"
|
||||
load_dotenv(dotenv_path=ROOT_DIR / ".env")
|
||||
|
||||
app = FastAPI()
|
||||
logger = logging.getLogger("tts")
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
@@ -103,6 +106,7 @@ def api_create_tts(payload: TtsCreateRequest):
|
||||
try:
|
||||
text_to_mp3(text=text, mp3_path=str(mp3_path))
|
||||
except Exception as exc:
|
||||
logger.exception("TTS 생성 실패")
|
||||
delete_item_by_id(tts_id)
|
||||
raise HTTPException(status_code=500, detail=str(exc)) from exc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user