Update index.html
Browse files- index.html +160 -184
index.html
CHANGED
@@ -3,31 +3,29 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title
|
7 |
<style>
|
8 |
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700;800&display=swap');
|
9 |
|
10 |
:root {
|
11 |
--app-font: 'Vazirmatn', sans-serif;
|
12 |
-
--bg-color
|
13 |
-
--
|
14 |
-
--
|
|
|
15 |
--glass-border: rgba(255, 255, 255, 0.1);
|
16 |
-
--text-primary: #
|
17 |
-
--text-secondary: #
|
18 |
-
--
|
19 |
-
--accent-color-hover: #5eead4;
|
20 |
-
--accent-glow: rgba(45, 212, 191, 0.3);
|
21 |
-
--radius-card: 24px;
|
22 |
-
--radius-input: 12px;
|
23 |
-
--shadow-card: 0 10px 30px -5px rgba(0,0,0,0.2);
|
24 |
}
|
25 |
|
26 |
body {
|
27 |
font-family: var(--app-font);
|
28 |
direction: rtl;
|
29 |
-
background-color: var(--bg-color
|
30 |
-
background-image: radial-gradient(circle at
|
|
|
|
|
31 |
color: var(--text-primary);
|
32 |
font-size: 16px;
|
33 |
line-height: 1.7;
|
@@ -39,209 +37,201 @@
|
|
39 |
overflow-x: hidden;
|
40 |
}
|
41 |
|
42 |
-
.container { max-width:
|
43 |
-
.app-header { text-align: center; margin-bottom:
|
44 |
-
.app-header h1 {
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
-
.main-
|
48 |
display: grid;
|
49 |
-
grid-template-columns:
|
50 |
gap: 2.5rem;
|
|
|
51 |
}
|
52 |
|
53 |
/* --- پنل شیشهای --- */
|
54 |
-
.
|
55 |
background: var(--glass-bg);
|
56 |
-
backdrop-filter: blur(
|
57 |
-
-webkit-backdrop-filter: blur(
|
58 |
border: 1px solid var(--glass-border);
|
59 |
-
border-radius: var(--radius
|
60 |
padding: 2.5rem;
|
61 |
-
box-shadow:
|
62 |
}
|
63 |
|
64 |
.form-group { margin-bottom: 2rem; }
|
65 |
-
label { display: block; font-weight:
|
66 |
textarea, input[type="text"] {
|
67 |
-
width: 100%;
|
68 |
-
padding: 1rem;
|
69 |
-
border-radius: var(--radius-input);
|
70 |
border: 1px solid var(--glass-border);
|
71 |
-
background-color: rgba(
|
72 |
-
box-
|
73 |
-
font-family: var(--app-font);
|
74 |
-
font-size: 1rem;
|
75 |
-
box-sizing: border-box;
|
76 |
-
color: var(--text-primary);
|
77 |
transition: all 0.3s ease;
|
78 |
}
|
79 |
textarea:focus, input[type="text"]:focus {
|
80 |
-
outline: none;
|
81 |
-
|
82 |
-
background-color: rgba(31, 41, 55, 0.9);
|
83 |
-
box-shadow: 0 0 15px var(--accent-glow);
|
84 |
}
|
85 |
|
86 |
-
/* --- گوینده
|
87 |
#selected-speaker-card {
|
88 |
-
display: flex;
|
89 |
-
|
90 |
-
|
91 |
-
border-radius: var(--radius-input);
|
92 |
-
padding: 1rem;
|
93 |
-
border: 1px solid var(--glass-border);
|
94 |
-
cursor: pointer;
|
95 |
-
transition: all 0.3s ease;
|
96 |
}
|
97 |
-
#selected-speaker-card:hover { border-color: var(--
|
98 |
-
#selected-speaker-card img { width:
|
99 |
-
#selected-speaker-info h3 { margin: 0; font-size: 1.
|
100 |
-
#selected-speaker-info p { margin: 2px 0 0; color: var(--text-secondary); font-size: 0.
|
101 |
-
|
102 |
-
/* --- مودال --- */
|
103 |
-
#speaker-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(17, 24, 39, 0.7); backdrop-filter: blur(10px); display: none; align-items: center; justify-content: center; z-index: 1000; opacity: 0; transition: opacity 0.3s ease; }
|
104 |
-
#speaker-modal.visible { display: flex; opacity: 1; }
|
105 |
-
.modal-content { background: var(--glass-bg); border: 1px solid var(--glass-border); padding: 2rem; border-radius: var(--radius-card); width: 90%; max-width: 700px; max-height: 85vh; overflow-y: auto; transform: scale(0.95); transition: transform 0.3s ease; box-shadow: 0 20px 50px rgba(0,0,0,0.3); }
|
106 |
-
#speaker-modal.visible .modal-content { transform: scale(1); }
|
107 |
-
.modal-header h2 { color: var(--text-primary); }
|
108 |
-
.close-modal-btn { color: var(--text-secondary); }
|
109 |
-
#speaker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 1.5rem; }
|
110 |
-
.speaker-card .speaker-visual { border: 3px solid transparent; border-radius: var(--radius-card); transition: all 0.3s ease; background: rgba(17, 24, 39, 0.8); }
|
111 |
-
.speaker-card:hover .speaker-visual { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(0,0,0,0.3); border-color: var(--accent-color); }
|
112 |
-
.speaker-card input[type="radio"]:checked + .speaker-visual { border-color: var(--accent-color); box-shadow: 0 0 20px var(--accent-glow); }
|
113 |
-
.speaker-card .speaker-name { color: var(--text-secondary); }
|
114 |
-
.speaker-card:hover .speaker-name, .speaker-card input[type="radio"]:checked + .speaker-visual .speaker-name { color: var(--text-primary); }
|
115 |
|
116 |
-
/* ---
|
117 |
-
input[type="range"] { flex-grow: 1; -webkit-appearance: none; appearance: none; width: 100%; height: 6px; background: rgba(17, 24, 39, 0.8); border-radius: 5px; outline: none; border: 1px solid var(--glass-border); }
|
118 |
-
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 24px; height: 24px; background: var(--accent-color); border-radius: 50%; cursor: pointer; transition: all 0.2s; box-shadow: 0 0 10px var(--accent-glow); }
|
119 |
-
input[type="range"]::-webkit-slider-thumb:hover { background: var(--accent-color-hover); box-shadow: 0 0 20px var(--accent-glow); }
|
120 |
-
#temperature-value { font-weight: 700; color: var(--accent-color); min-width: 45px; text-align: center; }
|
121 |
#generate-btn {
|
122 |
-
width: 100%; padding: 1rem; font-size: 1.
|
123 |
-
background: var(--
|
124 |
-
|
125 |
-
|
|
|
126 |
}
|
127 |
-
#generate-btn:hover:not(:disabled) {
|
128 |
-
#generate-btn:disabled { background: #
|
129 |
|
130 |
/* --- پنل خروجی و انیمیشن --- */
|
131 |
-
#
|
132 |
-
#
|
133 |
-
#
|
134 |
-
#audio-player { width: 100%; display: none; margin-top: 1rem; color-scheme: dark; }
|
135 |
|
136 |
-
/* --- انیمیشن
|
137 |
-
#
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
|
|
|
|
|
|
143 |
}
|
144 |
-
.
|
145 |
-
|
146 |
-
|
|
|
147 |
}
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
@keyframes core-breath {
|
153 |
-
0%, 100% { transform: scale(1); box-shadow: 0 0 30px var(--accent-color), 0 0 60px var(--accent-glow); }
|
154 |
-
50% { transform: scale(1.1); box-shadow: 0 0 45px var(--accent-color-hover), 0 0 90px var(--accent-glow); }
|
155 |
}
|
156 |
-
@keyframes
|
157 |
-
|
158 |
-
|
|
|
|
|
159 |
}
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
/* --- Responsive --- */
|
162 |
-
@media (max-width:
|
163 |
-
.main-
|
164 |
-
#
|
165 |
}
|
166 |
</style>
|
167 |
</head>
|
168 |
<body>
|
169 |
<div class="container">
|
170 |
<header class="app-header">
|
171 |
-
<h1
|
172 |
-
<p
|
173 |
</header>
|
174 |
|
175 |
-
<div class="main-
|
176 |
-
<div id="controls-panel" class="
|
177 |
<form id="tts-form">
|
178 |
<div class="form-group">
|
179 |
-
<label for="text-input"
|
180 |
-
<textarea id="text-input" rows="
|
181 |
</div>
|
182 |
<div class="form-group">
|
183 |
-
<label for="prompt-input"
|
184 |
<input type="text" id="prompt-input" value="با صدایی طبیعی و روان." placeholder="مثال: با لحنی حماسی و قدرتمند">
|
185 |
</div>
|
186 |
<div class="form-group">
|
187 |
-
<label>انتخاب
|
188 |
-
<div id="selected-speaker-card" role="button"
|
189 |
-
<img id="selected-speaker-img" src="" alt="
|
190 |
<div id="selected-speaker-info">
|
191 |
<h3 id="selected-speaker-name"></h3>
|
192 |
-
<p
|
193 |
</div>
|
194 |
</div>
|
195 |
</div>
|
196 |
-
<
|
197 |
-
<label for="temperature-slider">میزان خلاقیت</label>
|
198 |
-
<div class="slider-container" style="display: flex; align-items: center; gap: 1.5rem;">
|
199 |
-
<input type="range" id="temperature-slider" min="0.1" max="1.5" step="0.05" value="0.9">
|
200 |
-
<span id="temperature-value">0.9</span>
|
201 |
-
</div>
|
202 |
-
</div>
|
203 |
-
<button type="submit" id="generate-btn">ساخت صدا</button>
|
204 |
</form>
|
205 |
</div>
|
206 |
|
207 |
-
<div id="
|
208 |
-
<div id="
|
209 |
-
<
|
210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
</div>
|
212 |
-
|
213 |
-
<div id="loading-animation">
|
214 |
-
<div class="ai-core-container">
|
215 |
-
<div class="energy-ring ring-1"></div>
|
216 |
-
<div class="energy-ring ring-2"></div>
|
217 |
-
<div class="energy-ring ring-3"></div>
|
218 |
-
<div class="ai-core"></div>
|
219 |
-
</div>
|
220 |
-
<p id="loading-text">در حال ساخت... هسته هوش مصنوعی فعال شد</p>
|
221 |
-
</div>
|
222 |
-
|
223 |
-
<div id="status-message" style="display: none;"></div>
|
224 |
<audio id="audio-player" controls></audio>
|
225 |
</div>
|
226 |
</div>
|
227 |
</div>
|
228 |
|
229 |
-
<!-- Modal
|
230 |
-
<div id="speaker-modal">
|
231 |
-
<div class="modal-content">
|
232 |
-
<div
|
233 |
-
<h2>انتخاب
|
234 |
-
<button type="button" class="close-modal-btn" style="background: none; border: none; font-size: 2.2rem; cursor: pointer;
|
235 |
</div>
|
236 |
-
<div id="speaker-grid"></div>
|
237 |
</div>
|
238 |
</div>
|
239 |
|
240 |
<input type="hidden" id="selected_speaker_id_storage" value="Charon">
|
241 |
|
242 |
<script>
|
243 |
-
// جاوا اسکریپت بدون تغییر باقی میماند، چون منطق اصلی یکسان است
|
244 |
-
// اما برای هماهنگی با عناصر جدید، تغییراتی در نمایش وضعیت اعمال میکنیم
|
245 |
document.addEventListener('DOMContentLoaded', () => {
|
246 |
const HF_SPACE_URL = "https://hamed744-ttspro.hf.space";
|
247 |
const JOIN_QUEUE_URL = `${HF_SPACE_URL}/gradio_api/queue/join`;
|
@@ -249,26 +239,20 @@
|
|
249 |
const FILE_URL_BASE = `${HF_SPACE_URL}/gradio_api/file=`;
|
250 |
const FN_INDEX = 1;
|
251 |
|
252 |
-
const speakers = [
|
253 |
-
{ id: "Charon", name: "شهاب (مرد)" }, { id: "Zephyr", name: "آوا (زن)" }, { id: "Achird", name: "نوید (مرد)" }, { id: "Zubenelgenubi", name: "رویا (زن)" }, { id: "Vindemiatrix", name: "کیان (مرد)" }, { id: "Sadachbia", name: "پریسا (زن)" }, { id: "Sadaltager", name: "آرش (مرد)" }, { id: "Sulafat", name: "شبنم (زن)" }, { id: "Laomedeia", name: "سهیل (مرد)" }, { id: "Achernar", name: "مریم (زن)" }, { id: "Alnilam", name: "بهرام (مرد)" }, { id: "Schedar", name: "نگار (زن)" }, { id: "Gacrux", name: "فرید (مرد)" }, { id: "Pulcherrima", name: "سارا (زن)" }, { id: "Umbriel", name: "مانی (مرد)" }, { id: "Algieba", name: "آناهیتا (زن)" }, { id: "Despina", name: "دلنواز (زن)" }, { id: "Erinome", name: "رسا (مرد)" }, { id: "Algenib", name: "امید (مرد)" }, { id: "Rasalthgeti", name: "الهه (زن)" }, { id: "Orus", name: "بردیا (مرد)" }, { id: "Aoede", name: "ترانه (زن)" }, { id: "Callirrhoe", name: "نیما (مرد)" }, { id: "Autonoe", name: "هستی (زن)" }, { id: "Enceladus", name: "کامیار (مرد)" }, { id: "Iapetus", name: "ستاره (زن)" }, { id: "Puck", name: "پویا (مرد)" }, { id: "Kore", name: "مهتاب (زن)" }, { id: "Fenrir", name: "سام (مرد)" }, { id: "Leda", name: "لیدا (زن)" }
|
254 |
-
];
|
255 |
|
256 |
const form = document.getElementById('tts-form');
|
257 |
const textInput = document.getElementById('text-input');
|
258 |
const promptInput = document.getElementById('prompt-input');
|
259 |
-
const tempSlider = document.getElementById('temperature-slider');
|
260 |
-
const tempValueSpan = document.getElementById('temperature-value');
|
261 |
const generateBtn = document.getElementById('generate-btn');
|
262 |
|
263 |
-
// Output section elements
|
264 |
-
const outputInitialState = document.getElementById('output-initial-state');
|
265 |
const statusMessage = document.getElementById('status-message');
|
266 |
const audioPlayer = document.getElementById('audio-player');
|
267 |
-
const loadingAnimation = document.getElementById('
|
268 |
|
269 |
const selectedSpeakerIdStorage = document.getElementById('selected_speaker_id_storage');
|
270 |
const speakerModal = document.getElementById('speaker-modal');
|
271 |
-
const changeSpeakerBtn = document.getElementById('selected-speaker-card');
|
272 |
const closeModalBtn = document.querySelector('.close-modal-btn');
|
273 |
const speakerGridInModal = document.getElementById('speaker-grid');
|
274 |
const selectedSpeakerImgDisplay = document.getElementById('selected-speaker-img');
|
@@ -278,17 +262,18 @@
|
|
278 |
return speakers.find(s => s.id === id);
|
279 |
}
|
280 |
|
|
|
281 |
function getImageUrl(speaker, index) {
|
282 |
const gender = speaker.name.includes('(مرد)') ? 'men' : 'women';
|
283 |
-
const imageIndex = (index *
|
284 |
-
return `https://randomuser.me/api/portraits/
|
285 |
}
|
286 |
|
287 |
function updateSelectedSpeakerDisplay(speakerId) {
|
288 |
const speaker = getSpeakerById(speakerId);
|
289 |
if (speaker) {
|
290 |
const speakerIndex = speakers.findIndex(s => s.id === speakerId);
|
291 |
-
selectedSpeakerImgDisplay.src = getImageUrl(speaker, speakerIndex);
|
292 |
selectedSpeakerNameDisplay.textContent = speaker.name;
|
293 |
selectedSpeakerIdStorage.value = speaker.id;
|
294 |
}
|
@@ -302,10 +287,10 @@
|
|
302 |
card.setAttribute('for', `modal-speaker-${speaker.id}`);
|
303 |
const isChecked = speaker.id === selectedSpeakerIdStorage.value ? 'checked' : '';
|
304 |
card.innerHTML = `
|
305 |
-
<input type="radio" name="modal_speaker_selection" value="${speaker.id}" id="modal-speaker-${speaker.id}"
|
306 |
<div class="speaker-visual">
|
307 |
-
<img src="${getImageUrl(speaker, index)}" alt="${speaker.name}" loading="lazy" style="width: 100%; height: 120px; object-fit: cover; display: block;">
|
308 |
-
<div class="speaker-name" style="padding: 0.8rem 0.5rem; font-weight: 500;">${speaker.name}</div>
|
309 |
</div>
|
310 |
`;
|
311 |
card.addEventListener('click', () => {
|
@@ -318,17 +303,15 @@
|
|
318 |
|
319 |
changeSpeakerBtn.addEventListener('click', () => {
|
320 |
createSpeakerCardsInModal();
|
321 |
-
speakerModal.
|
|
|
322 |
});
|
323 |
-
closeModalBtn.addEventListener('click', () =>
|
324 |
-
|
325 |
-
|
326 |
});
|
327 |
|
328 |
-
tempSlider.addEventListener('input', () => { tempValueSpan.textContent = tempSlider.value; });
|
329 |
-
|
330 |
function showLoadingState() {
|
331 |
-
outputInitialState.style.display = 'none';
|
332 |
statusMessage.style.display = 'none';
|
333 |
audioPlayer.style.display = 'none';
|
334 |
audioPlayer.src = '';
|
@@ -345,10 +328,9 @@
|
|
345 |
} else {
|
346 |
statusMessage.textContent = message || 'یک خطای ناشناخته رخ داد.';
|
347 |
statusMessage.style.display = 'block';
|
348 |
-
statusMessage.style.color = '#f87171';
|
349 |
}
|
350 |
generateBtn.disabled = false;
|
351 |
-
generateBtn.textContent = '
|
352 |
}
|
353 |
|
354 |
async function generateAudio(event) {
|
@@ -357,20 +339,19 @@
|
|
357 |
|
358 |
const text = textInput.value;
|
359 |
if (!text.trim()) {
|
360 |
-
showResultState(false, 'خطا:
|
361 |
return;
|
362 |
}
|
363 |
|
364 |
const prompt = promptInput.value;
|
365 |
-
const temperature =
|
366 |
const selectedSpeaker = selectedSpeakerIdStorage.value;
|
367 |
const sessionHash = Math.random().toString(36).substring(2);
|
368 |
|
369 |
const payload = {
|
370 |
fn_index: FN_INDEX,
|
371 |
data: [false, null, text, prompt, selectedSpeaker, temperature],
|
372 |
-
event_data: null,
|
373 |
-
session_hash: sessionHash
|
374 |
};
|
375 |
|
376 |
try {
|
@@ -395,10 +376,8 @@
|
|
395 |
if (!line.startsWith('data:')) continue;
|
396 |
try {
|
397 |
const data = JSON.parse(line.substring(5));
|
398 |
-
if (data.msg === 'process_completed') {
|
399 |
-
|
400 |
-
finalFilePath = data.output.data[0].name || data.output.data[0].path;
|
401 |
-
}
|
402 |
break;
|
403 |
}
|
404 |
} catch (e) {}
|
@@ -409,11 +388,8 @@
|
|
409 |
if (finalFilePath) {
|
410 |
audioPlayer.src = `${FILE_URL_BASE}${finalFilePath}`;
|
411 |
showResultState(true);
|
412 |
-
} else {
|
413 |
-
throw new Error('فایل صوتی از سرور دریافت نشد.');
|
414 |
-
}
|
415 |
} catch (error) {
|
416 |
-
console.error('یک خطا در فرآیند رخ داد:', error);
|
417 |
showResultState(false, `یک خطا رخ داد: ${error.message}`);
|
418 |
}
|
419 |
}
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>پروژه تکینگی | Alpha TTS</title>
|
7 |
<style>
|
8 |
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700;800&display=swap');
|
9 |
|
10 |
:root {
|
11 |
--app-font: 'Vazirmatn', sans-serif;
|
12 |
+
--bg-color: #0d0c22;
|
13 |
+
--primary-glow: #f43f9a;
|
14 |
+
--secondary-glow: #a93ff4;
|
15 |
+
--glass-bg: rgba(22, 21, 53, 0.4);
|
16 |
--glass-border: rgba(255, 255, 255, 0.1);
|
17 |
+
--text-primary: #f0f2f5;
|
18 |
+
--text-secondary: #a0a3bd;
|
19 |
+
--radius: 16px;
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
|
22 |
body {
|
23 |
font-family: var(--app-font);
|
24 |
direction: rtl;
|
25 |
+
background-color: var(--bg-color);
|
26 |
+
background-image: radial-gradient(circle at 10% 20%, rgba(169, 63, 244, 0.2), transparent 30%),
|
27 |
+
radial-gradient(circle at 80% 90%, rgba(244, 63, 154, 0.2), transparent 40%);
|
28 |
+
background-attachment: fixed;
|
29 |
color: var(--text-primary);
|
30 |
font-size: 16px;
|
31 |
line-height: 1.7;
|
|
|
37 |
overflow-x: hidden;
|
38 |
}
|
39 |
|
40 |
+
.container { max-width: 1300px; width: 95%; margin: 0 auto; }
|
41 |
+
.app-header { text-align: center; margin-bottom: 3rem; }
|
42 |
+
.app-header h1 {
|
43 |
+
font-size: 3.2em;
|
44 |
+
font-weight: 800;
|
45 |
+
margin: 0;
|
46 |
+
background: -webkit-linear-gradient(45deg, var(--primary-glow), var(--secondary-glow));
|
47 |
+
-webkit-background-clip: text;
|
48 |
+
-webkit-text-fill-color: transparent;
|
49 |
+
text-shadow: 0 0 30px rgba(244, 63, 154, 0.3);
|
50 |
+
}
|
51 |
+
.app-header p { font-size: 1.2em; color: var(--text-secondary); margin-top: 0.5rem; }
|
52 |
|
53 |
+
.main-interface {
|
54 |
display: grid;
|
55 |
+
grid-template-columns: 450px 1fr;
|
56 |
gap: 2.5rem;
|
57 |
+
align-items: flex-start;
|
58 |
}
|
59 |
|
60 |
/* --- پنل شیشهای --- */
|
61 |
+
.glass-panel {
|
62 |
background: var(--glass-bg);
|
63 |
+
backdrop-filter: blur(15px);
|
64 |
+
-webkit-backdrop-filter: blur(15px);
|
65 |
border: 1px solid var(--glass-border);
|
66 |
+
border-radius: var(--radius);
|
67 |
padding: 2.5rem;
|
68 |
+
box-shadow: 0 10px 40px rgba(0,0,0,0.3);
|
69 |
}
|
70 |
|
71 |
.form-group { margin-bottom: 2rem; }
|
72 |
+
label { display: block; font-weight: 500; color: var(--text-secondary); font-size: 0.9em; margin-bottom: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px;}
|
73 |
textarea, input[type="text"] {
|
74 |
+
width: 100%; padding: 1rem; border-radius: 12px;
|
|
|
|
|
75 |
border: 1px solid var(--glass-border);
|
76 |
+
background-color: rgba(13, 12, 34, 0.7);
|
77 |
+
font-family: var(--app-font); font-size: 1rem; box-sizing: border-box; color: var(--text-primary);
|
|
|
|
|
|
|
|
|
78 |
transition: all 0.3s ease;
|
79 |
}
|
80 |
textarea:focus, input[type="text"]:focus {
|
81 |
+
outline: none; border-color: var(--primary-glow);
|
82 |
+
box-shadow: 0 0 15px rgba(244, 63, 154, 0.4);
|
|
|
|
|
83 |
}
|
84 |
|
85 |
+
/* --- گوینده --- */
|
86 |
#selected-speaker-card {
|
87 |
+
display: flex; align-items: center; background: rgba(13, 12, 34, 0.7);
|
88 |
+
border-radius: 12px; padding: 0.8rem; border: 1px solid var(--glass-border);
|
89 |
+
cursor: pointer; transition: all 0.3s ease;
|
|
|
|
|
|
|
|
|
|
|
90 |
}
|
91 |
+
#selected-speaker-card:hover { border-color: var(--primary-glow); background: rgba(22, 21, 53, 0.7); }
|
92 |
+
#selected-speaker-card img { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; margin-left: 15px; border: 2px solid var(--glass-border); }
|
93 |
+
#selected-speaker-info h3 { margin: 0; font-size: 1.1em; font-weight: 700; color: var(--text-primary); }
|
94 |
+
#selected-speaker-info p { margin: 2px 0 0; color: var(--text-secondary); font-size: 0.85em; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
+
/* --- دکمه اصلی --- */
|
|
|
|
|
|
|
|
|
97 |
#generate-btn {
|
98 |
+
width: 100%; padding: 1rem; font-size: 1.2em; font-weight: 700; font-family: var(--app-font);
|
99 |
+
background: linear-gradient(45deg, var(--primary-glow), var(--secondary-glow));
|
100 |
+
color: white; border: none; border-radius: 12px; cursor: pointer;
|
101 |
+
transition: all 0.3s ease;
|
102 |
+
box-shadow: 0 0 25px rgba(244, 63, 154, 0.4);
|
103 |
}
|
104 |
+
#generate-btn:hover:not(:disabled) { transform: translateY(-3px) scale(1.03); box-shadow: 0 0 40px rgba(244, 63, 154, 0.6); }
|
105 |
+
#generate-btn:disabled { background: #333; color: #777; cursor: not-allowed; box-shadow: none; transform: none; }
|
106 |
|
107 |
/* --- پنل خروجی و انیمیشن --- */
|
108 |
+
#visualization-panel { height: 100%; min-height: 550px; display: flex; align-items: center; justify-content: center; position: relative; }
|
109 |
+
#audio-player { width: 90%; max-width: 400px; display: none; color-scheme: dark; }
|
110 |
+
#status-message { color: #ff6b6b; font-weight: 500; display: none; }
|
|
|
111 |
|
112 |
+
/* --- انیمیشن رابط عصبی --- */
|
113 |
+
#animation-container { display: none; width: 100%; height: 100%; position: absolute; top: 0; left: 0; align-items: center; justify-content: center; flex-direction: column; overflow: hidden; }
|
114 |
+
#animation-svg { width: 300px; height: 300px; }
|
115 |
+
#ai-core { fill: url(#coreGradient); animation: core-pulse 3s infinite ease-in-out; }
|
116 |
+
.particle-path { fill: none; stroke: none; }
|
117 |
+
.particle { fill: var(--primary-glow); r: 2.5; animation: move-particle 4s infinite linear; opacity: 0; }
|
118 |
+
#particle-2 { animation-delay: -1s; } #particle-3 { animation-delay: -2s; } #particle-4 { animation-delay: -3s; }
|
119 |
+
#output-wave {
|
120 |
+
fill: none; stroke: url(#waveGradient); stroke-width: 4;
|
121 |
+
stroke-linecap: round; stroke-dasharray: 250; stroke-dashoffset: 250;
|
122 |
+
animation: draw-wave 2s infinite ease-out;
|
123 |
}
|
124 |
+
#loading-text { font-size: 1.1em; color: var(--text-secondary); margin-top: 2rem; text-shadow: 0 0 10px rgba(0,0,0,0.5); }
|
125 |
+
@keyframes core-pulse {
|
126 |
+
0%, 100% { transform: scale(1); filter: drop-shadow(0 0 15px var(--primary-glow)); }
|
127 |
+
50% { transform: scale(1.05); filter: drop-shadow(0 0 25px var(--secondary-glow)); }
|
128 |
}
|
129 |
+
@keyframes move-particle {
|
130 |
+
0% { offset-distance: 0%; opacity: 1; }
|
131 |
+
80% { opacity: 1; }
|
132 |
+
100% { offset-distance: 100%; opacity: 0; }
|
|
|
|
|
|
|
133 |
}
|
134 |
+
@keyframes draw-wave {
|
135 |
+
0% { stroke-dashoffset: 250; opacity: 0; }
|
136 |
+
30% { opacity: 1; }
|
137 |
+
80% { stroke-dashoffset: 0; }
|
138 |
+
100% { stroke-dashoffset: -250; opacity: 0; }
|
139 |
}
|
140 |
|
141 |
+
/* --- مودال --- */
|
142 |
+
#speaker-modal { background-color: rgba(13, 12, 34, 0.7); backdrop-filter: blur(10px); }
|
143 |
+
.modal-content { background: var(--glass-bg); border: 1px solid var(--glass-border); }
|
144 |
+
.speaker-card .speaker-visual { border: 2px solid transparent; transition: all 0.3s ease; background: rgba(13, 12, 34, 0.8); border-radius: 12px; }
|
145 |
+
.speaker-card:hover .speaker-visual, .speaker-card input[type="radio"]:checked + .speaker-visual { border-color: var(--primary-glow); box-shadow: 0 0 15px rgba(244, 63, 154, 0.4); }
|
146 |
+
|
147 |
/* --- Responsive --- */
|
148 |
+
@media (max-width: 1100px) {
|
149 |
+
.main-interface { grid-template-columns: 1fr; }
|
150 |
+
#visualization-panel { min-height: 350px; margin-top: 2rem; }
|
151 |
}
|
152 |
</style>
|
153 |
</head>
|
154 |
<body>
|
155 |
<div class="container">
|
156 |
<header class="app-header">
|
157 |
+
<h1>پروژه تکینگی | Alpha</h1>
|
158 |
+
<p>رابط عصبی تولید صوت</p>
|
159 |
</header>
|
160 |
|
161 |
+
<div class="main-interface">
|
162 |
+
<div id="controls-panel" class="glass-panel">
|
163 |
<form id="tts-form">
|
164 |
<div class="form-group">
|
165 |
+
<label for="text-input">دیتای ورودی (متن)</label>
|
166 |
+
<textarea id="text-input" rows="7" placeholder="ترکیب کلمات برای سنتز صوت...">این یک آزمایش برای بررسی کیفیت صدای تولید شده توسط هوش مصنوعی آلفا است.</textarea>
|
167 |
</div>
|
168 |
<div class="form-group">
|
169 |
+
<label for="prompt-input">پارامترهای لحن (اختیاری)</label>
|
170 |
<input type="text" id="prompt-input" value="با صدایی طبیعی و روان." placeholder="مثال: با لحنی حماسی و قدرتمند">
|
171 |
</div>
|
172 |
<div class="form-group">
|
173 |
+
<label>انتخاب مدل صوتی (گوینده)</label>
|
174 |
+
<div id="selected-speaker-card" role="button">
|
175 |
+
<img id="selected-speaker-img" src="" alt="مدل صوتی">
|
176 |
<div id="selected-speaker-info">
|
177 |
<h3 id="selected-speaker-name"></h3>
|
178 |
+
<p>تغییر مدل</p>
|
179 |
</div>
|
180 |
</div>
|
181 |
</div>
|
182 |
+
<button type="submit" id="generate-btn">سنتز و پردازش</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
</form>
|
184 |
</div>
|
185 |
|
186 |
+
<div id="visualization-panel" class="glass-panel">
|
187 |
+
<div id="animation-container">
|
188 |
+
<svg id="animation-svg" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
189 |
+
<defs>
|
190 |
+
<radialGradient id="coreGradient">
|
191 |
+
<stop offset="0%" stop-color="#fff" />
|
192 |
+
<stop offset="70%" stop-color="#f43f9a" />
|
193 |
+
<stop offset="100%" stop-color="#a93ff4" />
|
194 |
+
</radialGradient>
|
195 |
+
<linearGradient id="waveGradient">
|
196 |
+
<stop offset="0%" stop-color="#a93ff4" />
|
197 |
+
<stop offset="100%" stop-color="#f43f9a" />
|
198 |
+
</linearGradient>
|
199 |
+
</defs>
|
200 |
+
<!-- Particle Paths -->
|
201 |
+
<path id="path1" class="particle-path" d="M 0,100 C 50,20 50,180 100,100" />
|
202 |
+
<path id="path2" class="particle-path" d="M 200,100 C 150,180 150,20 100,100" />
|
203 |
+
<!-- Particles -->
|
204 |
+
<circle class="particle" id="particle-1"><animateMotion dur="4s" repeatCount="indefinite" rotate="auto"><mpath href="#path1"/></animateMotion></circle>
|
205 |
+
<circle class="particle" id="particle-2"><animateMotion dur="4s" repeatCount="indefinite" rotate="auto"><mpath href="#path1"/></animateMotion></circle>
|
206 |
+
<circle class="particle" id="particle-3"><animateMotion dur="4s" repeatCount="indefinite" rotate="auto"><mpath href="#path2"/></animateMotion></circle>
|
207 |
+
<circle class="particle" id="particle-4"><animateMotion dur="4s" repeatCount="indefinite" rotate="auto"><mpath href="#path2"/></animateMotion></circle>
|
208 |
+
<!-- AI Core -->
|
209 |
+
<circle id="ai-core" cx="100" cy="100" r="30" transform-origin="center" />
|
210 |
+
<!-- Output Wave -->
|
211 |
+
<path id="output-wave" d="M 100,100 C 150,50 200,150 250,100" />
|
212 |
+
</svg>
|
213 |
+
<p id="loading-text">در حال پردازش در هسته عصبی...</p>
|
214 |
</div>
|
215 |
+
<div id="status-message"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
<audio id="audio-player" controls></audio>
|
217 |
</div>
|
218 |
</div>
|
219 |
</div>
|
220 |
|
221 |
+
<!-- Modal (styles will be inherited) -->
|
222 |
+
<div id="speaker-modal" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: none; align-items: center; justify-content: center; z-index: 1000; opacity: 0; transition: opacity 0.3s ease;">
|
223 |
+
<div class="modal-content" style="padding: 2rem; width: 90%; max-width: 700px; max-height: 85vh; overflow-y: auto; transform: scale(0.95); transition: transform 0.3s ease;">
|
224 |
+
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--glass-border);">
|
225 |
+
<h2>انتخاب مدل صوتی</h2>
|
226 |
+
<button type="button" class="close-modal-btn" style="background: none; border: none; font-size: 2.2rem; cursor: pointer; color: var(--text-secondary);">×</button>
|
227 |
</div>
|
228 |
+
<div id="speaker-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 1.5rem;"></div>
|
229 |
</div>
|
230 |
</div>
|
231 |
|
232 |
<input type="hidden" id="selected_speaker_id_storage" value="Charon">
|
233 |
|
234 |
<script>
|
|
|
|
|
235 |
document.addEventListener('DOMContentLoaded', () => {
|
236 |
const HF_SPACE_URL = "https://hamed744-ttspro.hf.space";
|
237 |
const JOIN_QUEUE_URL = `${HF_SPACE_URL}/gradio_api/queue/join`;
|
|
|
239 |
const FILE_URL_BASE = `${HF_SPACE_URL}/gradio_api/file=`;
|
240 |
const FN_INDEX = 1;
|
241 |
|
242 |
+
const speakers = [ { id: "Charon", name: "شهاب (مرد)" }, { id: "Zephyr", name: "آوا (زن)" }, { id: "Achird", name: "نوید (مرد)" }, { id: "Zubenelgenubi", name: "رویا (زن)" }, { id: "Vindemiatrix", name: "کیان (مرد)" }, { id: "Sadachbia", name: "پریسا (زن)" }, { id: "Sadaltager", name: "آرش (مرد)" }, { id: "Sulafat", name: "شبنم (زن)" }, { id: "Laomedeia", name: "سهیل (مرد)" }, { id: "Achernar", name: "مریم (زن)" }, { id: "Alnilam", name: "بهرام (مرد)" }, { id: "Schedar", name: "نگار (زن)" }, { id: "Gacrux", name: "فرید (مرد)" }, { id: "Pulcherrima", name: "سارا (زن)" }, { id: "Umbriel", name: "مانی (مرد)" }, { id: "Algieba", name: "آناهیتا (زن)" } ];
|
|
|
|
|
243 |
|
244 |
const form = document.getElementById('tts-form');
|
245 |
const textInput = document.getElementById('text-input');
|
246 |
const promptInput = document.getElementById('prompt-input');
|
|
|
|
|
247 |
const generateBtn = document.getElementById('generate-btn');
|
248 |
|
|
|
|
|
249 |
const statusMessage = document.getElementById('status-message');
|
250 |
const audioPlayer = document.getElementById('audio-player');
|
251 |
+
const loadingAnimation = document.getElementById('animation-container');
|
252 |
|
253 |
const selectedSpeakerIdStorage = document.getElementById('selected_speaker_id_storage');
|
254 |
const speakerModal = document.getElementById('speaker-modal');
|
255 |
+
const changeSpeakerBtn = document.getElementById('selected-speaker-card');
|
256 |
const closeModalBtn = document.querySelector('.close-modal-btn');
|
257 |
const speakerGridInModal = document.getElementById('speaker-grid');
|
258 |
const selectedSpeakerImgDisplay = document.getElementById('selected-speaker-img');
|
|
|
262 |
return speakers.find(s => s.id === id);
|
263 |
}
|
264 |
|
265 |
+
// --- FIX: Correctly determine gender for image URL ---
|
266 |
function getImageUrl(speaker, index) {
|
267 |
const gender = speaker.name.includes('(مرد)') ? 'men' : 'women';
|
268 |
+
const imageIndex = (index * 11 + 7) % 100; // Use a different formula for variety
|
269 |
+
return `https://randomuser.me/api/portraits/thumb/${gender}/${imageIndex}.jpg`;
|
270 |
}
|
271 |
|
272 |
function updateSelectedSpeakerDisplay(speakerId) {
|
273 |
const speaker = getSpeakerById(speakerId);
|
274 |
if (speaker) {
|
275 |
const speakerIndex = speakers.findIndex(s => s.id === speakerId);
|
276 |
+
selectedSpeakerImgDisplay.src = getImageUrl(speaker, speakerIndex).replace('thumb/', '');
|
277 |
selectedSpeakerNameDisplay.textContent = speaker.name;
|
278 |
selectedSpeakerIdStorage.value = speaker.id;
|
279 |
}
|
|
|
287 |
card.setAttribute('for', `modal-speaker-${speaker.id}`);
|
288 |
const isChecked = speaker.id === selectedSpeakerIdStorage.value ? 'checked' : '';
|
289 |
card.innerHTML = `
|
290 |
+
<input type="radio" name="modal_speaker_selection" value="${speaker.id}" id="modal-speaker-${speaker.id}" style="display:none;">
|
291 |
<div class="speaker-visual">
|
292 |
+
<img src="${getImageUrl(speaker, index)}" alt="${speaker.name}" loading="lazy" style="width: 100%; height: 120px; object-fit: cover; display: block; border-radius: 10px 10px 0 0;">
|
293 |
+
<div class="speaker-name" style="padding: 0.8rem 0.5rem; font-weight: 500; color: var(--text-secondary);">${speaker.name}</div>
|
294 |
</div>
|
295 |
`;
|
296 |
card.addEventListener('click', () => {
|
|
|
303 |
|
304 |
changeSpeakerBtn.addEventListener('click', () => {
|
305 |
createSpeakerCardsInModal();
|
306 |
+
speakerModal.style.display = 'flex';
|
307 |
+
setTimeout(() => speakerModal.style.opacity = '1', 10);
|
308 |
});
|
309 |
+
closeModalBtn.addEventListener('click', () => {
|
310 |
+
speakerModal.style.opacity = '0';
|
311 |
+
setTimeout(() => speakerModal.style.display = 'none', 300);
|
312 |
});
|
313 |
|
|
|
|
|
314 |
function showLoadingState() {
|
|
|
315 |
statusMessage.style.display = 'none';
|
316 |
audioPlayer.style.display = 'none';
|
317 |
audioPlayer.src = '';
|
|
|
328 |
} else {
|
329 |
statusMessage.textContent = message || 'یک خطای ناشناخته رخ داد.';
|
330 |
statusMessage.style.display = 'block';
|
|
|
331 |
}
|
332 |
generateBtn.disabled = false;
|
333 |
+
generateBtn.textContent = 'سنتز و پردازش';
|
334 |
}
|
335 |
|
336 |
async function generateAudio(event) {
|
|
|
339 |
|
340 |
const text = textInput.value;
|
341 |
if (!text.trim()) {
|
342 |
+
showResultState(false, 'خطا: دیتای ورودی (متن) نمیتواند خالی باشد.');
|
343 |
return;
|
344 |
}
|
345 |
|
346 |
const prompt = promptInput.value;
|
347 |
+
const temperature = 0.9; // Simplified for this design, can be re-added
|
348 |
const selectedSpeaker = selectedSpeakerIdStorage.value;
|
349 |
const sessionHash = Math.random().toString(36).substring(2);
|
350 |
|
351 |
const payload = {
|
352 |
fn_index: FN_INDEX,
|
353 |
data: [false, null, text, prompt, selectedSpeaker, temperature],
|
354 |
+
event_data: null, session_hash: sessionHash
|
|
|
355 |
};
|
356 |
|
357 |
try {
|
|
|
376 |
if (!line.startsWith('data:')) continue;
|
377 |
try {
|
378 |
const data = JSON.parse(line.substring(5));
|
379 |
+
if (data.msg === 'process_completed' && data.success && data.output.data[0]) {
|
380 |
+
finalFilePath = data.output.data[0].name || data.output.data[0].path;
|
|
|
|
|
381 |
break;
|
382 |
}
|
383 |
} catch (e) {}
|
|
|
388 |
if (finalFilePath) {
|
389 |
audioPlayer.src = `${FILE_URL_BASE}${finalFilePath}`;
|
390 |
showResultState(true);
|
391 |
+
} else { throw new Error('فایل صوتی از سرور دریافت نشد.'); }
|
|
|
|
|
392 |
} catch (error) {
|
|
|
393 |
showResultState(false, `یک خطا رخ داد: ${error.message}`);
|
394 |
}
|
395 |
}
|