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:
dsyoon
2026-01-30 21:32:20 +09:00
parent ebd6a574d4
commit 21a29a6c8a
5 changed files with 60 additions and 16 deletions

View File

@@ -1,6 +1,7 @@
const listEl = document.getElementById("tts-list");
const textInput = document.getElementById("text-input");
const saveBtn = document.getElementById("save-btn");
const voiceSelect = document.getElementById("voice-select");
const editBtn = document.getElementById("edit-btn");
const deleteBtn = document.getElementById("delete-btn");
const cancelBtn = document.getElementById("cancel-btn");
@@ -111,6 +112,7 @@ async function loadList() {
async function handleSave() {
const text = (textInput.value || "").trim();
const voice = (voiceSelect?.value || "male").trim();
if (text.length < 11) {
alert("10개 글자 이상이어야 합니다");
return;
@@ -120,7 +122,7 @@ async function handleSave() {
const res = await fetch("/api/tts", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ text }),
body: JSON.stringify({ text, voice }),
});
if (!res.ok) {

View File

@@ -42,6 +42,21 @@ textarea {
flex: 1;
}
.save-row {
display: flex;
gap: 12px;
align-items: center;
}
.voice-select {
border: 1px solid #c9c9c9;
border-radius: 4px;
padding: 10px 12px;
font-size: 14px;
background: #ffffff;
color: #333;
}
button {
border: none;
padding: 12px 18px;

View File

@@ -11,7 +11,13 @@
<section class="panel left">
<div class="panel-header">입력 텍스트</div>
<textarea id="text-input" rows="16" placeholder="텍스트를 입력하세요"></textarea>
<button id="save-btn" class="primary">mp3 저장</button>
<div class="save-row">
<button id="save-btn" class="primary">mp3 변환</button>
<select id="voice-select" class="voice-select" aria-label="음성 선택">
<option value="male">남성#1</option>
<option value="female">여성#1</option>
</select>
</div>
<div id="save-progress" class="progress-wrap hidden" aria-label="저장 진행률">
<div
id="save-progress-bar"