Add voice selection control
Expose a voice selector next to the save button and pass the choice to TTS so pyttsx3 can prefer a female voice.
This commit is contained in:
@@ -48,6 +48,7 @@ templates = Jinja2Templates(directory=str(CLIENT_DIR / "templates"))
|
||||
|
||||
class TtsCreateRequest(BaseModel):
|
||||
text: str
|
||||
voice: str | None = None
|
||||
|
||||
|
||||
class TtsDeleteRequest(BaseModel):
|
||||
@@ -125,6 +126,7 @@ def api_list_tts():
|
||||
@app.post("/api/tts")
|
||||
def api_create_tts(payload: TtsCreateRequest):
|
||||
text = (payload.text or "").strip()
|
||||
voice = (payload.voice or "").strip().lower()
|
||||
if len(text) < 11:
|
||||
raise HTTPException(status_code=400, detail="텍스트는 11글자 이상이어야 합니다.")
|
||||
|
||||
@@ -137,7 +139,7 @@ def api_create_tts(payload: TtsCreateRequest):
|
||||
mp3_path = RESOURCES_DIR / filename
|
||||
|
||||
try:
|
||||
text_to_mp3(text=text, mp3_path=str(mp3_path))
|
||||
text_to_mp3(text=text, mp3_path=str(mp3_path), voice=voice)
|
||||
except Exception as exc:
|
||||
logger.exception("TTS 생성 실패")
|
||||
delete_item_by_id(tts_id)
|
||||
|
||||
Reference in New Issue
Block a user