Update index.html
Browse files- index.html +309 -29
index.html
CHANGED
|
@@ -8,10 +8,9 @@
|
|
| 8 |
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');
|
| 9 |
:root { --app-font: 'Vazirmatn', sans-serif; --app-bg: #F8F9FC; --panel-bg: #FFFFFF; --panel-border: #EAEFF7; --input-bg: #F6F8FB; --input-border: #E1E7EF; --text-primary: #1A202C; --text-secondary: #626F86; --text-tertiary: #8A94A6; --accent-primary: #4A6CFA; --accent-primary-hover: #3553D6; --accent-primary-glow: rgba(74, 108, 250, 0.25); --accent-secondary: #0FD4A8; --accent-secondary-hover: #0DA986; --accent-secondary-glow: rgba(15, 212, 168, 0.2); --accent-premium: #FFC107; --accent-premium-glow: rgba(255, 193, 7, 0.3); --waveform-color-active: var(--accent-primary); --waveform-color-inactive: #D0D9E6; --waveform-dashed-line-color: #E0E4E9; --shadow-sm: 0 1px 2px 0 rgba(26, 32, 44, 0.03); --shadow-md: 0 4px 6px -1px rgba(26, 32, 44, 0.05), 0 2px 4px -2px rgba(26, 32, 44, 0.04); --shadow-lg: 0 10px 15px -3px rgba(26, 32, 44, 0.06), 0 4px 6px -4px rgba(26, 32, 44, 0.05); --shadow-xl: 0 20px 25px -5px rgba(26, 32, 44, 0.07), 0 8px 10px -6px rgba(26, 32, 44, 0.05); --radius-card: 24px; --radius-btn: 14px; --radius-input: 12px; --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); --transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1); --transition-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55); } @keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } } @keyframes modalZoomIn { from { opacity: 0; transform: scale(0.9) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } } @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes rotate-loader-orbital { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes orbit-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes satellite-pulse-1 { from { transform: scale(0.7) translateX(-50%); opacity: 0.6; } to { transform: scale(1.1) translateX(-50%); opacity: 1; } } @keyframes satellite-pulse-2 { from { transform: scale(0.7) translateY(-50%); opacity: 0.6; } to { transform: scale(1.1) translateY(-50%); opacity: 1; } } @keyframes satellite-pulse-3 { from { transform: scale(0.7) translateX(50%); opacity: 0.6; } to { transform: scale(1.1) translateX(50%); opacity: 1; } } @keyframes badge-fade-in { from { opacity: 0; transform: translateY(-10px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } } .subscription-status-badge { display: inline-block; padding: 6px 16px; border-radius: 20px; font-size: 0.9em; font-weight: 700; margin-top: 1rem; letter-spacing: 0.5px; text-shadow: 0 1px 2px rgba(0,0,0,0.1); animation: badge-fade-in 0.6s 0.5s ease-out backwards; display: none; } .subscription-status-badge.free-badge { background: linear-gradient(45deg, #6c757d, #495057); color: white; box-shadow: 0 4px 10px rgba(108, 117, 125, 0.3); } .subscription-status-badge.paid-badge { background: linear-gradient(45deg, var(--accent-premium), #ffca2c); color: #333; box-shadow: 0 4px 10px var(--accent-premium-glow); } html { scroll-behavior: smooth; } body { font-family: var(--app-font); direction: rtl; background-color: var(--app-bg); color: var(--text-primary); font-size: 16px; line-height: 1.8; margin: 0; padding: 2.5rem 0; min-height: 100vh; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; display: flex; justify-content: center; align-items: flex-start; overflow-x: hidden; background-image: radial-gradient(var(--text-tertiary) 0.5px, transparent 0.5px); background-size: 20px 20px; background-position: -10px -10px; } .app-container { max-width: 820px; width: 92%; margin: 0 auto; } .app-header { padding: 0.5rem 0 2.5rem 0; text-align: center; margin-bottom: 1.5rem; animation: fadeIn 0.8s 0.2s ease-out backwards; } .app-header h1 { font-size: 2.5em; font-weight: 900; margin: 0 0 0.8rem 0; background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: -1px; } .app-header p { font-size: 1.05em; color: var(--text-secondary); margin-top: 0; opacity: 0.9; font-weight: 400; line-height: 1.7; } .main-content { position:relative; padding: 3rem; background-color: var(--panel-bg); border-radius: var(--radius-card); box-shadow: var(--shadow-xl); border: 1px solid var(--panel-border); animation: fadeIn 0.8s 0.4s ease-out backwards; } .form-group { margin-bottom: 2.2rem; } label { display: block; font-weight: 700; color: var(--text-primary); font-size: 1.1em; margin-bottom: 1rem; } textarea, input[type="text"] { width: 100%; padding: 1rem 1.2rem; border-radius: var(--radius-input); border: 1px solid var(--input-border); background-color: var(--input-bg); color: var(--text-primary); box-shadow: var(--shadow-sm) inset; font-family: var(--app-font); font-size: 1rem; box-sizing: border-box; transition: var(--transition-smooth); } textarea:focus, input[type="text"]:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-primary-glow), var(--shadow-sm) inset; background-color: var(--panel-bg); } textarea { min-height: 120px; resize: vertical; } .slider-container { display: flex; align-items: center; gap: 1.5rem; } input[type="range"] { flex-grow: 1; -webkit-appearance: none; appearance: none; width: 100%; height: 6px; background: var(--input-border); border-radius: 3px; outline: none; cursor: pointer; } input[type="range"]::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--accent-secondary) 0%, var(--accent-primary) 100%); height: 6px; border-radius: 3px; } input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 24px; height: 24px; background: #fff; border-radius: 50%; cursor: pointer; border: 4px solid var(--accent-primary); box-shadow: var(--shadow-md); margin-top: -9px; transition: var(--transition-fast); } input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.15); box-shadow: 0 0 0 8px var(--accent-primary-glow); } .temperature-value { font-weight: 700; background-color: var(--input-bg); padding: 0.5rem 1rem; border-radius: 8px; border: 1px solid var(--input-border); min-width: 45px; text-align: center; color: var(--accent-primary); font-size: 1em; box-shadow: var(--shadow-sm); } .generate-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 1.1rem 1.5rem; font-size: 1.25em; font-weight: 800; background: linear-gradient(95deg, var(--accent-secondary) 0%, var(--accent-primary) 100%); color: #fff; border: none; border-radius: var(--radius-btn); cursor: pointer; transition: all 0.3s ease; box-shadow: 0 6px 12px -3px var(--accent-primary-glow), 0 6px 12px -3px var(--accent-secondary-glow); position: relative; overflow: hidden; letter-spacing: 0.5px; } .generate-btn:hover:not(:disabled) { transform: translateY(-5px) scale(1.02); box-shadow: 0 8px 20px -4px var(--accent-primary-glow), 0 8px 20px -4px var(--accent-secondary-glow); } .generate-btn:disabled { background: var(--text-tertiary); cursor: not-allowed; box-shadow: none; color: rgba(255,255,255,0.7); } .generate-btn .spinner { width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; display: none;} .output-section { margin-top: 3rem; display: flex; align-items: center; justify-content: center; flex-direction: column; min-height: 220px; position: relative; box-sizing: border-box; padding: 2rem; background-color: var(--input-bg); border-radius: var(--radius-card); border: 2px dashed var(--input-border); box-shadow: var(--shadow-sm) inset; transition: var(--transition-smooth); } .output-section.has-content { background-color: var(--panel-bg); border: 1px solid var(--panel-border); box-shadow: var(--shadow-lg); padding: 0; min-height: auto; } .status-message { font-weight: 500; color: var(--text-secondary); text-align: center; font-size: 1.1em; } .status-message.error { color: var(--text-primary); font-weight: 600; line-height: 1.9; } .loading-animation-wrapper { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 1.8rem; width: 100%; } .orbital-loader { width: 110px; height: 110px; position: relative; animation: rotate-loader-orbital 10s linear infinite; } .orbit { position: absolute; top: 50%; left: 50%; border: 2px dashed rgba(74, 108, 250, 0.35); border-radius: 50%; transform-origin: center center; } .orbit:nth-child(1) { width: 35px; height: 35px; margin: -17.5px 0 0 -17.5px; animation: orbit-spin 2.8s linear infinite reverse; } .orbit:nth-child(2) { width: 65px; height: 65px; margin: -32.5px 0 0 -32.5px; animation: orbit-spin 3.8s linear infinite; } .orbit:nth-child(3) { width: 95px; height: 95px; margin: -47.5px 0 0 -47.5px; animation: orbit-spin 4.8s linear infinite reverse; } .orbit .satellite { position: absolute; width: 10px; height: 10px; border-radius: 50%; background-color: var(--accent-primary); box-shadow: 0 0 8px var(--accent-primary), 0 0 12px var(--accent-secondary); } .orbit:nth-child(1) .satellite { top: -5px; left: 50%; animation: satellite-pulse-1 1.4s ease-in-out infinite alternate; } .orbit:nth-child(2) .satellite { top: 50%; left: -5px; background-color: var(--accent-secondary); animation: satellite-pulse-2 1.4s 0.2s ease-in-out infinite alternate; } .orbit:nth-child(3) .satellite { bottom: -5px; right: 50%; animation: satellite-pulse-3 1.4s 0.4s ease-in-out infinite alternate;} .loading-text { font-size: 1.2em; font-weight: 700; color: var(--text-primary); text-align: center; background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .audio-player-content { display: none; width: 100%; padding: 1.5rem; box-sizing: border-box; flex-direction: column; gap: 1.2rem; animation: fadeIn 0.5s ease-out; } .audio-waveform-container { display: flex; align-items: center; gap: 1rem; width: 100%; margin-bottom: 1rem; } .audio-time { font-size: 0.9em; color: var(--text-secondary); min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; user-select: none; } .audio-waveform { flex-grow: 1; height: 60px; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; margin-bottom: 0.5rem; } .audio-waveform-canvas { display: block; max-width: 100%; height: 100%; } .audio-waveform-dashed-line { position: absolute; top: 50%; left: 0; width: 100%; height: 1px; background-image: linear-gradient(to right, var(--waveform-dashed-line-color) 33%, transparent 0%); background-position: center; background-size: 10px 1px; z-index: 1; } .audio-controls-group { display: flex; justify-content: center; align-items: center; gap: 1.5rem; margin-bottom: 1rem; } .audio-skip-btn, .audio-play-pause-btn-large, .audio-volume-btn { background: none; border: none; cursor: pointer; padding: 8px; transition: transform 0.2s, opacity 0.2s; color: var(--text-secondary); } .audio-skip-btn:hover, .audio-play-pause-btn-large:hover, .audio-volume-btn:hover { color: var(--accent-primary); opacity: 0.9; } .audio-skip-btn:active, .audio-play-pause-btn-large:active, .audio-volume-btn:active { transform: scale(0.9); } .audio-skip-btn svg { width: 28px; height: 28px; fill: currentColor; } .audio-play-pause-btn-large { padding: 0; width: 50px; height: 50px; } .audio-play-pause-btn-large svg { width: 38px; height: 38px; fill: currentColor; } .audio-utility-controls { display: flex; align-items: center; justify-content: space-between; width: 100%; } .audio-volume-btn svg { width: 24px; height: 24px; fill: currentColor; } .audio-speed-btn { font-family: var(--app-font); font-size: 0.9em; font-weight: 600; background-color: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 8px; min-width: 40px; text-align: center; color: var(--text-primary); box-shadow: var(--shadow-sm); } .audio-speed-btn:hover { background-color: var(--input-bg); } #standard-view .char-counter-wrapper { font-size: 0.85em; color: var(--text-tertiary); text-align: left; margin-top: 0.75rem; padding: 0 0.2rem; } #standard-view #char-count { font-weight: 600; color: var(--accent-primary); } #standard-view #selected-speaker-display { text-align: center; margin-top: 1.5rem; }
|
| 10 |
|
| 11 |
-
/* --- START: اصلاحیه نهایی و قطعی استایل کارت گوینده --- */
|
| 12 |
#standard-view #selected-speaker-card {
|
| 13 |
display: inline-flex;
|
| 14 |
-
width: 320px;
|
| 15 |
max-width: 100%;
|
| 16 |
box-sizing: border-box;
|
| 17 |
align-items: center;
|
|
@@ -50,7 +49,6 @@
|
|
| 50 |
overflow: hidden;
|
| 51 |
text-overflow: ellipsis;
|
| 52 |
}
|
| 53 |
-
/* --- END: اصلاحیه نهایی --- */
|
| 54 |
|
| 55 |
#standard-view #selected-speaker-card:hover { transform: translateY(-6px) scale(1.03); box-shadow: var(--shadow-lg); border-color: var(--accent-primary); }
|
| 56 |
#standard-view #selected-speaker-info h3 { margin: 0; font-size: 1.25em; font-weight: 800; }
|
|
@@ -102,7 +100,6 @@
|
|
| 102 |
#upgrade-premium-btn { display: none; width: 100%; margin-top: 1.5rem; padding: 1rem; font-family: var(--app-font); font-size: 1.1em; font-weight: 800; color: #212529; background: linear-gradient(95deg, #FFD54F, var(--accent-premium) 100%); border: none; border-radius: var(--radius-btn); cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; box-shadow: 0 8px 20px -5px var(--accent-premium-glow); }
|
| 103 |
#upgrade-premium-btn:hover { transform: translateY(-3px); box-shadow: 0 12px 25px -5px rgba(255, 193, 7, 0.4); }
|
| 104 |
|
| 105 |
-
/* --- START: استایلهای جدید برای کارت اختصاصی و دانلود --- */
|
| 106 |
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
|
| 107 |
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
|
| 108 |
|
|
@@ -187,7 +184,53 @@
|
|
| 187 |
background-color: rgba(255, 255, 255, 0.3);
|
| 188 |
transform: scale(1.05);
|
| 189 |
}
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
@media (max-width: 600px) {
|
| 193 |
body { padding: 1.5rem 0; }
|
|
@@ -287,6 +330,17 @@
|
|
| 287 |
</button>
|
| 288 |
</div>
|
| 289 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
</main>
|
| 291 |
</div>
|
| 292 |
<audio id="hidden-audio-player" style="display: none;"></audio>
|
|
@@ -549,6 +603,7 @@
|
|
| 549 |
['timeupdate', 'play', 'pause', 'ended'].forEach(e => mainAudioPlayer.addEventListener(e, updatePlayerUI));
|
| 550 |
window.addEventListener('resize', updatePlayerUI);
|
| 551 |
|
|
|
|
| 552 |
(function() {
|
| 553 |
const form = document.getElementById('standard-tts-form'), textInput = document.getElementById('text-input-standard'), promptInput = document.getElementById('prompt-input-standard'), tempSlider = document.getElementById('temperature-slider-standard'), tempValueSpan = document.getElementById('temperature-value-standard'), generateBtn = document.getElementById('generate-btn-standard'), btnText = generateBtn.querySelector('.btn-text'), btnSpinner = generateBtn.querySelector('.spinner'), outputSection = document.getElementById('output-section-standard'), statusMessage = document.getElementById('status-message-standard'), loadingAnimation = document.getElementById('loading-animation-wrapper-standard'), playerContent = document.getElementById('audio-player-content-standard'), charCount = document.getElementById('char-count'), charMax = document.getElementById('char-max'), MAX_CHARS = 50000;
|
| 554 |
const downloadWrapper = document.getElementById('download-wrapper-standard');
|
|
@@ -605,14 +660,105 @@
|
|
| 605 |
createPlayerInstance('audio-player-content-standard'); statusMessage.style.display = 'block';
|
| 606 |
})();
|
| 607 |
|
|
|
|
| 608 |
(function() {
|
| 609 |
-
const view = voiceCloneView
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 610 |
const downloadWrapper = document.getElementById('download-wrapper-clone');
|
| 611 |
const downloadBtn = document.getElementById('download-btn-clone');
|
| 612 |
const longTextWarning = view.querySelector('#long-text-warning-clone');
|
|
|
|
|
|
|
| 613 |
const LONG_TEXT_THRESHOLD = 5000;
|
| 614 |
-
const
|
| 615 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 616 |
let lastSelectedFile = null;
|
| 617 |
const handleFileSelect = (file) => { if (file) { lastSelectedFile = file; fileNameSpan.textContent = file.name; uploadArea.style.display = 'none'; filePreview.style.display = 'flex'; audioPreview.src = URL.createObjectURL(file); } };
|
| 618 |
uploadArea.addEventListener('click', () => { userVoiceInput.value = ''; userVoiceInput.click(); });
|
|
@@ -625,9 +771,12 @@
|
|
| 625 |
audioPreview.addEventListener('pause', () => { previewPlayIcon.style.display = 'block'; previewPauseIcon.style.display = 'none'; });
|
| 626 |
audioPreview.addEventListener('ended', () => { previewPlayIcon.style.display = 'block'; previewPauseIcon.style.display = 'none'; });
|
| 627 |
tempSlider.addEventListener('input', () => tempValueSpan.textContent = tempSlider.value);
|
|
|
|
|
|
|
|
|
|
| 628 |
const callTtsApi = async (text, prompt, temp) => {
|
| 629 |
return new Promise((resolve, reject) => {
|
| 630 |
-
fetch(
|
| 631 |
.then(res => {
|
| 632 |
if (res.status === 429) { return res.json().then(err => reject(new Error(err.message || "اعتبار روزانه شما تمام شده است."))); }
|
| 633 |
if (!res.ok) { return res.json().then(err => reject(new Error(err.error || `سرویس متن به صدا خطا داد (${res.status})`))); }
|
|
@@ -635,9 +784,7 @@
|
|
| 635 |
})
|
| 636 |
.then(data => {
|
| 637 |
const jobId = data.job_id;
|
| 638 |
-
const POLLING_INTERVAL = 4000; const MAX_ATTEMPTS = 1275; let attempts = 0;
|
| 639 |
const intervalId = setInterval(async () => {
|
| 640 |
-
if (attempts++ > MAX_ATTEMPTS) { clearInterval(intervalId); reject(new Error('زمان پردازش صدای اولیه طولانی شد.')); }
|
| 641 |
try {
|
| 642 |
const statusRes = await fetch('/api/check_status', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ job_id: jobId }) });
|
| 643 |
if (!statusRes.ok) return;
|
|
@@ -650,14 +797,131 @@
|
|
| 650 |
reject(new Error(statusData.result || 'خطای ناشناخته در تولید صدای اولیه.'));
|
| 651 |
}
|
| 652 |
} catch (e) { console.error(e); }
|
| 653 |
-
},
|
| 654 |
})
|
| 655 |
.catch(reject);
|
| 656 |
});
|
| 657 |
};
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 661 |
form.addEventListener('submit', async () => {
|
| 662 |
const text = textInput.value;
|
| 663 |
if (!text.trim() || !lastSelectedFile) { alert("لطفاً هم متن و هم فایل صوتی را وارد کنید."); return; }
|
|
@@ -670,20 +934,38 @@
|
|
| 670 |
}
|
| 671 |
|
| 672 |
showUIState('loading'); loadingText.textContent = 'مرحله ۱: تولید صدای اولیه...';
|
|
|
|
| 673 |
try {
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 683 |
});
|
| 684 |
|
| 685 |
-
|
| 686 |
-
|
|
|
|
| 687 |
})();
|
| 688 |
|
| 689 |
async function initializeApp() {
|
|
@@ -693,10 +975,8 @@
|
|
| 693 |
|
| 694 |
updateSelectedSpeakerDisplay(selectedSpeakerIdStorage.value || speakers[0].id);
|
| 695 |
|
| 696 |
-
// --- START: کد جدید برای قفل کردن اندازه کارت ---
|
| 697 |
const speakerCardToLock = document.getElementById('selected-speaker-card');
|
| 698 |
if (speakerCardToLock) {
|
| 699 |
-
// یک تاخیر کوتاه میدهیم تا مرورگر فرصت محاسبه اندازه اولیه را داشته باشد
|
| 700 |
setTimeout(() => {
|
| 701 |
const initialWidth = speakerCardToLock.offsetWidth;
|
| 702 |
if (initialWidth > 0) {
|
|
@@ -704,10 +984,10 @@
|
|
| 704 |
}
|
| 705 |
}, 100);
|
| 706 |
}
|
| 707 |
-
// --- END: کد جدید برای قفل کردن اندازه کارت ---
|
| 708 |
|
| 709 |
initializeApp();
|
| 710 |
});
|
| 711 |
</script>
|
|
|
|
| 712 |
</body>
|
| 713 |
</html>
|
|
|
|
| 8 |
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800;900&display=swap');
|
| 9 |
:root { --app-font: 'Vazirmatn', sans-serif; --app-bg: #F8F9FC; --panel-bg: #FFFFFF; --panel-border: #EAEFF7; --input-bg: #F6F8FB; --input-border: #E1E7EF; --text-primary: #1A202C; --text-secondary: #626F86; --text-tertiary: #8A94A6; --accent-primary: #4A6CFA; --accent-primary-hover: #3553D6; --accent-primary-glow: rgba(74, 108, 250, 0.25); --accent-secondary: #0FD4A8; --accent-secondary-hover: #0DA986; --accent-secondary-glow: rgba(15, 212, 168, 0.2); --accent-premium: #FFC107; --accent-premium-glow: rgba(255, 193, 7, 0.3); --waveform-color-active: var(--accent-primary); --waveform-color-inactive: #D0D9E6; --waveform-dashed-line-color: #E0E4E9; --shadow-sm: 0 1px 2px 0 rgba(26, 32, 44, 0.03); --shadow-md: 0 4px 6px -1px rgba(26, 32, 44, 0.05), 0 2px 4px -2px rgba(26, 32, 44, 0.04); --shadow-lg: 0 10px 15px -3px rgba(26, 32, 44, 0.06), 0 4px 6px -4px rgba(26, 32, 44, 0.05); --shadow-xl: 0 20px 25px -5px rgba(26, 32, 44, 0.07), 0 8px 10px -6px rgba(26, 32, 44, 0.05); --radius-card: 24px; --radius-btn: 14px; --radius-input: 12px; --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); --transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1); --transition-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55); } @keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } } @keyframes modalZoomIn { from { opacity: 0; transform: scale(0.9) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } } @keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes rotate-loader-orbital { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes orbit-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes satellite-pulse-1 { from { transform: scale(0.7) translateX(-50%); opacity: 0.6; } to { transform: scale(1.1) translateX(-50%); opacity: 1; } } @keyframes satellite-pulse-2 { from { transform: scale(0.7) translateY(-50%); opacity: 0.6; } to { transform: scale(1.1) translateY(-50%); opacity: 1; } } @keyframes satellite-pulse-3 { from { transform: scale(0.7) translateX(50%); opacity: 0.6; } to { transform: scale(1.1) translateX(50%); opacity: 1; } } @keyframes badge-fade-in { from { opacity: 0; transform: translateY(-10px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } } .subscription-status-badge { display: inline-block; padding: 6px 16px; border-radius: 20px; font-size: 0.9em; font-weight: 700; margin-top: 1rem; letter-spacing: 0.5px; text-shadow: 0 1px 2px rgba(0,0,0,0.1); animation: badge-fade-in 0.6s 0.5s ease-out backwards; display: none; } .subscription-status-badge.free-badge { background: linear-gradient(45deg, #6c757d, #495057); color: white; box-shadow: 0 4px 10px rgba(108, 117, 125, 0.3); } .subscription-status-badge.paid-badge { background: linear-gradient(45deg, var(--accent-premium), #ffca2c); color: #333; box-shadow: 0 4px 10px var(--accent-premium-glow); } html { scroll-behavior: smooth; } body { font-family: var(--app-font); direction: rtl; background-color: var(--app-bg); color: var(--text-primary); font-size: 16px; line-height: 1.8; margin: 0; padding: 2.5rem 0; min-height: 100vh; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; display: flex; justify-content: center; align-items: flex-start; overflow-x: hidden; background-image: radial-gradient(var(--text-tertiary) 0.5px, transparent 0.5px); background-size: 20px 20px; background-position: -10px -10px; } .app-container { max-width: 820px; width: 92%; margin: 0 auto; } .app-header { padding: 0.5rem 0 2.5rem 0; text-align: center; margin-bottom: 1.5rem; animation: fadeIn 0.8s 0.2s ease-out backwards; } .app-header h1 { font-size: 2.5em; font-weight: 900; margin: 0 0 0.8rem 0; background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; letter-spacing: -1px; } .app-header p { font-size: 1.05em; color: var(--text-secondary); margin-top: 0; opacity: 0.9; font-weight: 400; line-height: 1.7; } .main-content { position:relative; padding: 3rem; background-color: var(--panel-bg); border-radius: var(--radius-card); box-shadow: var(--shadow-xl); border: 1px solid var(--panel-border); animation: fadeIn 0.8s 0.4s ease-out backwards; } .form-group { margin-bottom: 2.2rem; } label { display: block; font-weight: 700; color: var(--text-primary); font-size: 1.1em; margin-bottom: 1rem; } textarea, input[type="text"] { width: 100%; padding: 1rem 1.2rem; border-radius: var(--radius-input); border: 1px solid var(--input-border); background-color: var(--input-bg); color: var(--text-primary); box-shadow: var(--shadow-sm) inset; font-family: var(--app-font); font-size: 1rem; box-sizing: border-box; transition: var(--transition-smooth); } textarea:focus, input[type="text"]:focus { outline: none; border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-primary-glow), var(--shadow-sm) inset; background-color: var(--panel-bg); } textarea { min-height: 120px; resize: vertical; } .slider-container { display: flex; align-items: center; gap: 1.5rem; } input[type="range"] { flex-grow: 1; -webkit-appearance: none; appearance: none; width: 100%; height: 6px; background: var(--input-border); border-radius: 3px; outline: none; cursor: pointer; } input[type="range"]::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--accent-secondary) 0%, var(--accent-primary) 100%); height: 6px; border-radius: 3px; } input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 24px; height: 24px; background: #fff; border-radius: 50%; cursor: pointer; border: 4px solid var(--accent-primary); box-shadow: var(--shadow-md); margin-top: -9px; transition: var(--transition-fast); } input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.15); box-shadow: 0 0 0 8px var(--accent-primary-glow); } .temperature-value { font-weight: 700; background-color: var(--input-bg); padding: 0.5rem 1rem; border-radius: 8px; border: 1px solid var(--input-border); min-width: 45px; text-align: center; color: var(--accent-primary); font-size: 1em; box-shadow: var(--shadow-sm); } .generate-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 1.1rem 1.5rem; font-size: 1.25em; font-weight: 800; background: linear-gradient(95deg, var(--accent-secondary) 0%, var(--accent-primary) 100%); color: #fff; border: none; border-radius: var(--radius-btn); cursor: pointer; transition: all 0.3s ease; box-shadow: 0 6px 12px -3px var(--accent-primary-glow), 0 6px 12px -3px var(--accent-secondary-glow); position: relative; overflow: hidden; letter-spacing: 0.5px; } .generate-btn:hover:not(:disabled) { transform: translateY(-5px) scale(1.02); box-shadow: 0 8px 20px -4px var(--accent-primary-glow), 0 8px 20px -4px var(--accent-secondary-glow); } .generate-btn:disabled { background: var(--text-tertiary); cursor: not-allowed; box-shadow: none; color: rgba(255,255,255,0.7); } .generate-btn .spinner { width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, 0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; display: none;} .output-section { margin-top: 3rem; display: flex; align-items: center; justify-content: center; flex-direction: column; min-height: 220px; position: relative; box-sizing: border-box; padding: 2rem; background-color: var(--input-bg); border-radius: var(--radius-card); border: 2px dashed var(--input-border); box-shadow: var(--shadow-sm) inset; transition: var(--transition-smooth); } .output-section.has-content { background-color: var(--panel-bg); border: 1px solid var(--panel-border); box-shadow: var(--shadow-lg); padding: 0; min-height: auto; } .status-message { font-weight: 500; color: var(--text-secondary); text-align: center; font-size: 1.1em; } .status-message.error { color: var(--text-primary); font-weight: 600; line-height: 1.9; } .loading-animation-wrapper { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 1.8rem; width: 100%; } .orbital-loader { width: 110px; height: 110px; position: relative; animation: rotate-loader-orbital 10s linear infinite; } .orbit { position: absolute; top: 50%; left: 50%; border: 2px dashed rgba(74, 108, 250, 0.35); border-radius: 50%; transform-origin: center center; } .orbit:nth-child(1) { width: 35px; height: 35px; margin: -17.5px 0 0 -17.5px; animation: orbit-spin 2.8s linear infinite reverse; } .orbit:nth-child(2) { width: 65px; height: 65px; margin: -32.5px 0 0 -32.5px; animation: orbit-spin 3.8s linear infinite; } .orbit:nth-child(3) { width: 95px; height: 95px; margin: -47.5px 0 0 -47.5px; animation: orbit-spin 4.8s linear infinite reverse; } .orbit .satellite { position: absolute; width: 10px; height: 10px; border-radius: 50%; background-color: var(--accent-primary); box-shadow: 0 0 8px var(--accent-primary), 0 0 12px var(--accent-secondary); } .orbit:nth-child(1) .satellite { top: -5px; left: 50%; animation: satellite-pulse-1 1.4s ease-in-out infinite alternate; } .orbit:nth-child(2) .satellite { top: 50%; left: -5px; background-color: var(--accent-secondary); animation: satellite-pulse-2 1.4s 0.2s ease-in-out infinite alternate; } .orbit:nth-child(3) .satellite { bottom: -5px; right: 50%; animation: satellite-pulse-3 1.4s 0.4s ease-in-out infinite alternate;} .loading-text { font-size: 1.2em; font-weight: 700; color: var(--text-primary); text-align: center; background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } .audio-player-content { display: none; width: 100%; padding: 1.5rem; box-sizing: border-box; flex-direction: column; gap: 1.2rem; animation: fadeIn 0.5s ease-out; } .audio-waveform-container { display: flex; align-items: center; gap: 1rem; width: 100%; margin-bottom: 1rem; } .audio-time { font-size: 0.9em; color: var(--text-secondary); min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; user-select: none; } .audio-waveform { flex-grow: 1; height: 60px; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; margin-bottom: 0.5rem; } .audio-waveform-canvas { display: block; max-width: 100%; height: 100%; } .audio-waveform-dashed-line { position: absolute; top: 50%; left: 0; width: 100%; height: 1px; background-image: linear-gradient(to right, var(--waveform-dashed-line-color) 33%, transparent 0%); background-position: center; background-size: 10px 1px; z-index: 1; } .audio-controls-group { display: flex; justify-content: center; align-items: center; gap: 1.5rem; margin-bottom: 1rem; } .audio-skip-btn, .audio-play-pause-btn-large, .audio-volume-btn { background: none; border: none; cursor: pointer; padding: 8px; transition: transform 0.2s, opacity 0.2s; color: var(--text-secondary); } .audio-skip-btn:hover, .audio-play-pause-btn-large:hover, .audio-volume-btn:hover { color: var(--accent-primary); opacity: 0.9; } .audio-skip-btn:active, .audio-play-pause-btn-large:active, .audio-volume-btn:active { transform: scale(0.9); } .audio-skip-btn svg { width: 28px; height: 28px; fill: currentColor; } .audio-play-pause-btn-large { padding: 0; width: 50px; height: 50px; } .audio-play-pause-btn-large svg { width: 38px; height: 38px; fill: currentColor; } .audio-utility-controls { display: flex; align-items: center; justify-content: space-between; width: 100%; } .audio-volume-btn svg { width: 24px; height: 24px; fill: currentColor; } .audio-speed-btn { font-family: var(--app-font); font-size: 0.9em; font-weight: 600; background-color: var(--panel-bg); border: 1px solid var(--panel-border); border-radius: 8px; min-width: 40px; text-align: center; color: var(--text-primary); box-shadow: var(--shadow-sm); } .audio-speed-btn:hover { background-color: var(--input-bg); } #standard-view .char-counter-wrapper { font-size: 0.85em; color: var(--text-tertiary); text-align: left; margin-top: 0.75rem; padding: 0 0.2rem; } #standard-view #char-count { font-weight: 600; color: var(--accent-primary); } #standard-view #selected-speaker-display { text-align: center; margin-top: 1.5rem; }
|
| 10 |
|
|
|
|
| 11 |
#standard-view #selected-speaker-card {
|
| 12 |
display: inline-flex;
|
| 13 |
+
width: 320px;
|
| 14 |
max-width: 100%;
|
| 15 |
box-sizing: border-box;
|
| 16 |
align-items: center;
|
|
|
|
| 49 |
overflow: hidden;
|
| 50 |
text-overflow: ellipsis;
|
| 51 |
}
|
|
|
|
| 52 |
|
| 53 |
#standard-view #selected-speaker-card:hover { transform: translateY(-6px) scale(1.03); box-shadow: var(--shadow-lg); border-color: var(--accent-primary); }
|
| 54 |
#standard-view #selected-speaker-info h3 { margin: 0; font-size: 1.25em; font-weight: 800; }
|
|
|
|
| 100 |
#upgrade-premium-btn { display: none; width: 100%; margin-top: 1.5rem; padding: 1rem; font-family: var(--app-font); font-size: 1.1em; font-weight: 800; color: #212529; background: linear-gradient(95deg, #FFD54F, var(--accent-premium) 100%); border: none; border-radius: var(--radius-btn); cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease; box-shadow: 0 8px 20px -5px var(--accent-premium-glow); }
|
| 101 |
#upgrade-premium-btn:hover { transform: translateY(-3px); box-shadow: 0 12px 25px -5px rgba(255, 193, 7, 0.4); }
|
| 102 |
|
|
|
|
| 103 |
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
|
| 104 |
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }
|
| 105 |
|
|
|
|
| 184 |
background-color: rgba(255, 255, 255, 0.3);
|
| 185 |
transform: scale(1.05);
|
| 186 |
}
|
| 187 |
+
|
| 188 |
+
/* --- Custom History Section Styles --- */
|
| 189 |
+
.history-container {
|
| 190 |
+
margin-top: 3rem;
|
| 191 |
+
background-color: var(--panel-bg);
|
| 192 |
+
border-radius: var(--radius-card);
|
| 193 |
+
border: 1px solid var(--panel-border);
|
| 194 |
+
padding: 1.5rem;
|
| 195 |
+
box-shadow: var(--shadow-lg);
|
| 196 |
+
animation: fadeIn 0.5s ease-out;
|
| 197 |
+
}
|
| 198 |
+
.history-header {
|
| 199 |
+
display: flex;
|
| 200 |
+
justify-content: space-between;
|
| 201 |
+
align-items: center;
|
| 202 |
+
margin-bottom: 1.5rem;
|
| 203 |
+
border-bottom: 1px solid var(--panel-border);
|
| 204 |
+
padding-bottom: 1rem;
|
| 205 |
+
}
|
| 206 |
+
.history-header h3 { margin: 0; font-size: 1.2em; font-weight: 800; color: var(--text-primary); }
|
| 207 |
+
.history-list { max-height: 500px; overflow-y: auto; }
|
| 208 |
+
.history-item {
|
| 209 |
+
background: var(--input-bg);
|
| 210 |
+
border: 1px solid var(--input-border);
|
| 211 |
+
border-radius: 16px;
|
| 212 |
+
padding: 15px;
|
| 213 |
+
margin-bottom: 12px;
|
| 214 |
+
transition: var(--transition-fast);
|
| 215 |
+
position: relative;
|
| 216 |
+
}
|
| 217 |
+
.history-item:hover { border-color: var(--accent-primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
|
| 218 |
+
.history-item-top { display: flex; justify-content: space-between; align-items: start; margin-bottom: 10px; }
|
| 219 |
+
.history-item-id { font-weight: 700; color: var(--text-primary); font-size: 0.9em; }
|
| 220 |
+
.history-item-date { font-size: 0.8em; color: var(--text-tertiary); margin-top: 4px; }
|
| 221 |
+
.history-badge { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }
|
| 222 |
+
.history-badge.completed { background-color: #DEF7EC; color: #03543F; }
|
| 223 |
+
.history-badge.processing { background-color: #FEF3C7; color: #92400E; }
|
| 224 |
+
.history-badge.failed { background-color: #FDE8E8; color: #9B1C1C; }
|
| 225 |
+
.history-actions { display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid rgba(0,0,0,0.05); padding-top: 10px; }
|
| 226 |
+
.btn-history-action { padding: 6px 12px; border-radius: 8px; font-size: 0.85em; font-weight: 600; cursor: pointer; border: none; transition: 0.2s; display: inline-flex; align-items: center; gap: 5px; }
|
| 227 |
+
.btn-play { background: var(--accent-primary); color: white; }
|
| 228 |
+
.btn-play:hover { background: var(--accent-primary-hover); }
|
| 229 |
+
.btn-track { background: var(--accent-premium); color: #333; }
|
| 230 |
+
.btn-track:hover { background: #e0a800; }
|
| 231 |
+
.btn-delete { background: #fff5f5; color: #e53e3e; border: 1px solid #fed7d7; }
|
| 232 |
+
.btn-delete:hover { background: #e53e3e; color: white; }
|
| 233 |
+
.empty-history { text-align: center; color: var(--text-tertiary); padding: 2rem; font-style: italic; }
|
| 234 |
|
| 235 |
@media (max-width: 600px) {
|
| 236 |
body { padding: 1.5rem 0; }
|
|
|
|
| 330 |
</button>
|
| 331 |
</div>
|
| 332 |
</div>
|
| 333 |
+
|
| 334 |
+
<!-- Custom Voice History Section -->
|
| 335 |
+
<div class="history-container" id="custom-history-section">
|
| 336 |
+
<div class="history-header">
|
| 337 |
+
<h3><i class="fas fa-history"></i> سوابق درخواستهای اختصاصی</h3>
|
| 338 |
+
</div>
|
| 339 |
+
<div class="history-list" id="custom-history-list">
|
| 340 |
+
<!-- History Items Will Be Injected Here -->
|
| 341 |
+
</div>
|
| 342 |
+
</div>
|
| 343 |
+
|
| 344 |
</main>
|
| 345 |
</div>
|
| 346 |
<audio id="hidden-audio-player" style="display: none;"></audio>
|
|
|
|
| 603 |
['timeupdate', 'play', 'pause', 'ended'].forEach(e => mainAudioPlayer.addEventListener(e, updatePlayerUI));
|
| 604 |
window.addEventListener('resize', updatePlayerUI);
|
| 605 |
|
| 606 |
+
// --- Standard View Logic (Unchanged) ---
|
| 607 |
(function() {
|
| 608 |
const form = document.getElementById('standard-tts-form'), textInput = document.getElementById('text-input-standard'), promptInput = document.getElementById('prompt-input-standard'), tempSlider = document.getElementById('temperature-slider-standard'), tempValueSpan = document.getElementById('temperature-value-standard'), generateBtn = document.getElementById('generate-btn-standard'), btnText = generateBtn.querySelector('.btn-text'), btnSpinner = generateBtn.querySelector('.spinner'), outputSection = document.getElementById('output-section-standard'), statusMessage = document.getElementById('status-message-standard'), loadingAnimation = document.getElementById('loading-animation-wrapper-standard'), playerContent = document.getElementById('audio-player-content-standard'), charCount = document.getElementById('char-count'), charMax = document.getElementById('char-max'), MAX_CHARS = 50000;
|
| 609 |
const downloadWrapper = document.getElementById('download-wrapper-standard');
|
|
|
|
| 660 |
createPlayerInstance('audio-player-content-standard'); statusMessage.style.display = 'block';
|
| 661 |
})();
|
| 662 |
|
| 663 |
+
// --- NEW: Voice Clone View Logic (Updated for Manager Space) ---
|
| 664 |
(function() {
|
| 665 |
+
const view = voiceCloneView;
|
| 666 |
+
const form = view.querySelector('#voice-clone-form');
|
| 667 |
+
const generateBtn = view.querySelector('#generate-btn-clone');
|
| 668 |
+
const btnText = generateBtn.querySelector('.btn-text');
|
| 669 |
+
const btnSpinner = generateBtn.querySelector('.spinner');
|
| 670 |
+
const textInput = view.querySelector('#text-input-clone');
|
| 671 |
+
const promptInput = view.querySelector('#prompt-input-clone');
|
| 672 |
+
const tempSlider = view.querySelector('#temperature-slider-clone');
|
| 673 |
+
const tempValueSpan = view.querySelector('#temperature-value-clone');
|
| 674 |
+
const userVoiceInput = view.querySelector('#user-voice-input');
|
| 675 |
+
const uploadArea = view.querySelector('#upload-area');
|
| 676 |
+
const filePreview = view.querySelector('#file-preview');
|
| 677 |
+
const fileNameSpan = view.querySelector('#file-name');
|
| 678 |
+
const removeFileBtn = view.querySelector('#remove-file-btn');
|
| 679 |
+
const previewPlayBtn = view.querySelector('.preview-play-btn');
|
| 680 |
+
const previewPlayIcon = previewPlayBtn.querySelector('.play-icon-preview');
|
| 681 |
+
const previewPauseIcon = previewPlayBtn.querySelector('.pause-icon-preview');
|
| 682 |
+
const audioPreview = view.querySelector('#audio-preview');
|
| 683 |
+
const outputSection = view.querySelector('#output-section-clone');
|
| 684 |
+
const statusMessage = view.querySelector('#status-message-clone');
|
| 685 |
+
const loadingAnimation = view.querySelector('#loading-animation-wrapper-clone');
|
| 686 |
+
const loadingText = view.querySelector('#loading-text-clone');
|
| 687 |
+
const playerContent = view.querySelector('#audio-player-content-clone');
|
| 688 |
const downloadWrapper = document.getElementById('download-wrapper-clone');
|
| 689 |
const downloadBtn = document.getElementById('download-btn-clone');
|
| 690 |
const longTextWarning = view.querySelector('#long-text-warning-clone');
|
| 691 |
+
const historyListContainer = document.getElementById('custom-history-list');
|
| 692 |
+
|
| 693 |
const LONG_TEXT_THRESHOLD = 5000;
|
| 694 |
+
const MANAGER_API_URL = "https://ezmary-sada.hf.space";
|
| 695 |
+
const TTS_API_ENDPOINT = "/api/generate"; // Keep using Alpha TTS to generate source audio
|
| 696 |
+
|
| 697 |
+
// --- Helper: LocalStorage Management for Custom Jobs ---
|
| 698 |
+
function getCustomJobs() {
|
| 699 |
+
return JSON.parse(localStorage.getItem('alpha_custom_voice_jobs') || '{}');
|
| 700 |
+
}
|
| 701 |
+
|
| 702 |
+
function saveCustomJob(data) {
|
| 703 |
+
const jobs = getCustomJobs();
|
| 704 |
+
jobs[data.job_id] = {
|
| 705 |
+
...data,
|
| 706 |
+
date: new Date().toLocaleDateString('fa-IR'),
|
| 707 |
+
timestamp: Date.now(),
|
| 708 |
+
textPreview: textInput.value.substring(0, 30) + '...'
|
| 709 |
+
};
|
| 710 |
+
localStorage.setItem('alpha_custom_voice_jobs', JSON.stringify(jobs));
|
| 711 |
+
renderHistory();
|
| 712 |
+
}
|
| 713 |
+
|
| 714 |
+
function updateCustomJob(id, updates) {
|
| 715 |
+
const jobs = getCustomJobs();
|
| 716 |
+
if(jobs[id]) {
|
| 717 |
+
jobs[id] = { ...jobs[id], ...updates };
|
| 718 |
+
localStorage.setItem('alpha_custom_voice_jobs', JSON.stringify(jobs));
|
| 719 |
+
renderHistory();
|
| 720 |
+
}
|
| 721 |
+
}
|
| 722 |
+
|
| 723 |
+
function deleteCustomJob(id) {
|
| 724 |
+
const jobs = getCustomJobs();
|
| 725 |
+
delete jobs[id];
|
| 726 |
+
localStorage.setItem('alpha_custom_voice_jobs', JSON.stringify(jobs));
|
| 727 |
+
renderHistory();
|
| 728 |
+
}
|
| 729 |
+
|
| 730 |
+
// --- Helper: UI State Management ---
|
| 731 |
+
const showUIState = (state, msg = '') => {
|
| 732 |
+
generateBtn.disabled = state === 'loading';
|
| 733 |
+
btnSpinner.style.display = state === 'loading' ? 'inline-block' : 'none';
|
| 734 |
+
btnText.textContent = state === 'loading' ? 'در حال پردازش...' : 'خلق صدا با آلفا';
|
| 735 |
+
|
| 736 |
+
outputSection.classList.remove('has-content');
|
| 737 |
+
statusMessage.style.display = 'none';
|
| 738 |
+
loadingAnimation.style.display = 'none';
|
| 739 |
+
playerContent.style.display = 'none';
|
| 740 |
+
downloadWrapper.style.display = 'none';
|
| 741 |
+
statusMessage.classList.remove('error');
|
| 742 |
+
|
| 743 |
+
if (state === 'initial') {
|
| 744 |
+
statusMessage.textContent = 'صدای نهایی در اینجا نمایش داده میشود.';
|
| 745 |
+
statusMessage.style.display = 'block';
|
| 746 |
+
} else if (state === 'loading') {
|
| 747 |
+
loadingAnimation.style.display = 'flex';
|
| 748 |
+
mainAudioPlayer.src = '';
|
| 749 |
+
audioPeaks = [];
|
| 750 |
+
} else if (state === 'result') {
|
| 751 |
+
playerContent.style.display = 'flex';
|
| 752 |
+
downloadWrapper.style.display = 'block';
|
| 753 |
+
outputSection.classList.add('has-content');
|
| 754 |
+
} else if (state === 'error') {
|
| 755 |
+
statusMessage.innerHTML = `<b>خطا:</b> ${msg}`;
|
| 756 |
+
statusMessage.style.display = 'block';
|
| 757 |
+
statusMessage.classList.add('error');
|
| 758 |
+
}
|
| 759 |
+
};
|
| 760 |
+
|
| 761 |
+
// --- Input Handlers ---
|
| 762 |
let lastSelectedFile = null;
|
| 763 |
const handleFileSelect = (file) => { if (file) { lastSelectedFile = file; fileNameSpan.textContent = file.name; uploadArea.style.display = 'none'; filePreview.style.display = 'flex'; audioPreview.src = URL.createObjectURL(file); } };
|
| 764 |
uploadArea.addEventListener('click', () => { userVoiceInput.value = ''; userVoiceInput.click(); });
|
|
|
|
| 771 |
audioPreview.addEventListener('pause', () => { previewPlayIcon.style.display = 'block'; previewPauseIcon.style.display = 'none'; });
|
| 772 |
audioPreview.addEventListener('ended', () => { previewPlayIcon.style.display = 'block'; previewPauseIcon.style.display = 'none'; });
|
| 773 |
tempSlider.addEventListener('input', () => tempValueSpan.textContent = tempSlider.value);
|
| 774 |
+
downloadBtn.addEventListener('click', () => handleDownloadRequest(downloadBtn));
|
| 775 |
+
|
| 776 |
+
// --- Core Logic: Call TTS API first ---
|
| 777 |
const callTtsApi = async (text, prompt, temp) => {
|
| 778 |
return new Promise((resolve, reject) => {
|
| 779 |
+
fetch(TTS_API_ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text, speaker: "Charon", temperature: temp, prompt, fingerprint: userFingerprint, subscriptionStatus: userSubscriptionStatus }) })
|
| 780 |
.then(res => {
|
| 781 |
if (res.status === 429) { return res.json().then(err => reject(new Error(err.message || "اعتبار روزانه شما تمام شده است."))); }
|
| 782 |
if (!res.ok) { return res.json().then(err => reject(new Error(err.error || `سرویس متن به صدا خطا داد (${res.status})`))); }
|
|
|
|
| 784 |
})
|
| 785 |
.then(data => {
|
| 786 |
const jobId = data.job_id;
|
|
|
|
| 787 |
const intervalId = setInterval(async () => {
|
|
|
|
| 788 |
try {
|
| 789 |
const statusRes = await fetch('/api/check_status', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ job_id: jobId }) });
|
| 790 |
if (!statusRes.ok) return;
|
|
|
|
| 797 |
reject(new Error(statusData.result || 'خطای ناشناخته در تولید صدای اولیه.'));
|
| 798 |
}
|
| 799 |
} catch (e) { console.error(e); }
|
| 800 |
+
}, 4000);
|
| 801 |
})
|
| 802 |
.catch(reject);
|
| 803 |
});
|
| 804 |
};
|
| 805 |
+
|
| 806 |
+
// --- Core Logic: Manager Interaction ---
|
| 807 |
+
const trackJob = (jobId) => {
|
| 808 |
+
const jobs = getCustomJobs();
|
| 809 |
+
const jobData = jobs[jobId];
|
| 810 |
+
if(!jobData) return;
|
| 811 |
+
|
| 812 |
+
// UI Update for Tracking
|
| 813 |
+
window.scrollTo({ top: 0, behavior: 'smooth' });
|
| 814 |
+
showUIState('loading');
|
| 815 |
+
loadingText.textContent = `در حال پیگیری وضعیت... (${jobData.progress || 0}%)`;
|
| 816 |
+
|
| 817 |
+
const pollingInterval = setInterval(async () => {
|
| 818 |
+
try {
|
| 819 |
+
// Manager expects ProjectState object in check_status
|
| 820 |
+
const response = await fetch(`${MANAGER_API_URL}/check_status`, {
|
| 821 |
+
method: 'POST',
|
| 822 |
+
headers: {'Content-Type': 'application/json'},
|
| 823 |
+
body: JSON.stringify(jobData)
|
| 824 |
+
});
|
| 825 |
+
|
| 826 |
+
const res = await response.json();
|
| 827 |
+
const p = res.progress || 0;
|
| 828 |
+
loadingText.textContent = `پردازش سرور موازی... ${p}%`;
|
| 829 |
+
|
| 830 |
+
updateCustomJob(jobId, { status: res.status, progress: p, filename: res.filename });
|
| 831 |
+
|
| 832 |
+
if(res.status === 'completed') {
|
| 833 |
+
clearInterval(pollingInterval);
|
| 834 |
+
const finalUrl = `${MANAGER_API_URL}/download/${res.filename}`;
|
| 835 |
+
mainAudioPlayer.src = finalUrl;
|
| 836 |
+
showUIState('result');
|
| 837 |
+
updateCustomJob(jobId, { status: 'completed', resultUrl: finalUrl, progress: 100 });
|
| 838 |
+
}
|
| 839 |
+
else if(res.status === 'error' || res.status === 'failed') {
|
| 840 |
+
clearInterval(pollingInterval);
|
| 841 |
+
showUIState('error', res.detail || 'خطا در پردازش سرور');
|
| 842 |
+
}
|
| 843 |
+
} catch(e) {
|
| 844 |
+
console.error(e);
|
| 845 |
+
// Don't clear interval immediately on network error, try again
|
| 846 |
+
}
|
| 847 |
+
}, 4000);
|
| 848 |
+
};
|
| 849 |
+
|
| 850 |
+
// --- History Rendering ---
|
| 851 |
+
window.playHistoryItem = (url) => {
|
| 852 |
+
window.scrollTo({ top: 0, behavior: 'smooth' });
|
| 853 |
+
mainAudioPlayer.src = url;
|
| 854 |
+
mainAudioPlayer.play();
|
| 855 |
+
showUIState('result');
|
| 856 |
+
};
|
| 857 |
+
|
| 858 |
+
window.trackHistoryItem = (id) => {
|
| 859 |
+
trackJob(id);
|
| 860 |
+
};
|
| 861 |
+
|
| 862 |
+
window.deleteHistoryItem = (id) => {
|
| 863 |
+
if(confirm('آیا از حذف این مورد اطمینان دارید؟')) {
|
| 864 |
+
deleteCustomJob(id);
|
| 865 |
+
}
|
| 866 |
+
};
|
| 867 |
+
|
| 868 |
+
const renderHistory = () => {
|
| 869 |
+
const jobs = getCustomJobs();
|
| 870 |
+
const list = Object.values(jobs).reverse();
|
| 871 |
+
historyListContainer.innerHTML = '';
|
| 872 |
+
|
| 873 |
+
if(list.length === 0) {
|
| 874 |
+
historyListContainer.innerHTML = '<div class="empty-history">لیست خالی است</div>';
|
| 875 |
+
return;
|
| 876 |
+
}
|
| 877 |
+
|
| 878 |
+
list.forEach(job => {
|
| 879 |
+
const el = document.createElement('div');
|
| 880 |
+
el.className = 'history-item';
|
| 881 |
+
|
| 882 |
+
let statusBadge, actionBtns = '';
|
| 883 |
+
|
| 884 |
+
if(job.status === 'completed') {
|
| 885 |
+
statusBadge = `<span class="history-badge completed">تکمیل شده</span>`;
|
| 886 |
+
actionBtns = `
|
| 887 |
+
<button onclick="playHistoryItem('${job.resultUrl || `${MANAGER_API_URL}/download/${job.filename}`}')" class="btn-history-action btn-play">
|
| 888 |
+
<i class="fas fa-play"></i> پخش
|
| 889 |
+
</button>
|
| 890 |
+
`;
|
| 891 |
+
} else if(job.status === 'started' || job.status === 'processing') {
|
| 892 |
+
statusBadge = `<span class="history-badge processing">در حال پردازش (${job.progress}%)</span>`;
|
| 893 |
+
actionBtns = `
|
| 894 |
+
<button onclick="trackHistoryItem('${job.job_id}')" class="btn-history-action btn-track">
|
| 895 |
+
<i class="fas fa-sync"></i> پیگیری
|
| 896 |
+
</button>
|
| 897 |
+
`;
|
| 898 |
+
} else {
|
| 899 |
+
statusBadge = `<span class="history-badge failed">خطا</span>`;
|
| 900 |
+
}
|
| 901 |
+
|
| 902 |
+
actionBtns += `
|
| 903 |
+
<button onclick="deleteHistoryItem('${job.job_id}')" class="btn-history-action btn-delete">
|
| 904 |
+
<i class="fas fa-trash"></i>
|
| 905 |
+
</button>
|
| 906 |
+
`;
|
| 907 |
+
|
| 908 |
+
el.innerHTML = `
|
| 909 |
+
<div class="history-item-top">
|
| 910 |
+
<div>
|
| 911 |
+
<div class="history-item-id">شناسه: ${job.job_id.substring(0,8)}...</div>
|
| 912 |
+
<div class="history-item-date">${job.date} | ${job.textPreview}</div>
|
| 913 |
+
</div>
|
| 914 |
+
<div>${statusBadge}</div>
|
| 915 |
+
</div>
|
| 916 |
+
<div class="history-actions">
|
| 917 |
+
${actionBtns}
|
| 918 |
+
</div>
|
| 919 |
+
`;
|
| 920 |
+
historyListContainer.appendChild(el);
|
| 921 |
+
});
|
| 922 |
+
};
|
| 923 |
+
|
| 924 |
+
// --- Form Submission ---
|
| 925 |
form.addEventListener('submit', async () => {
|
| 926 |
const text = textInput.value;
|
| 927 |
if (!text.trim() || !lastSelectedFile) { alert("لطفاً هم متن و هم فایل صوتی را وارد کنید."); return; }
|
|
|
|
| 934 |
}
|
| 935 |
|
| 936 |
showUIState('loading'); loadingText.textContent = 'مرحله ۱: تولید صدای اولیه...';
|
| 937 |
+
|
| 938 |
try {
|
| 939 |
+
// Step 1: Generate Source Audio (TTS)
|
| 940 |
+
const sourceBlob = await callTtsApi(text, promptInput.value, parseFloat(tempSlider.value));
|
| 941 |
+
|
| 942 |
+
loadingText.textContent = 'مرحله ۲: ارسال به سرور پردازش موازی...';
|
| 943 |
+
|
| 944 |
+
// Step 2: Prepare FormData for Manager
|
| 945 |
+
const fd = new FormData();
|
| 946 |
+
fd.append('source_audio', sourceBlob, 'src.wav');
|
| 947 |
+
fd.append('ref_audio', lastSelectedFile, 'ref.wav');
|
| 948 |
+
|
| 949 |
+
// Step 3: Upload to Manager
|
| 950 |
+
const response = await fetch(`${MANAGER_API_URL}/upload`, { method: 'POST', body: fd });
|
| 951 |
+
if(!response.ok) throw new Error('خطا در ارتباط با سرور مدیریت');
|
| 952 |
+
|
| 953 |
+
const result = await response.json(); // { job_id, total_chunks, chunks, status }
|
| 954 |
+
|
| 955 |
+
// Step 4: Save to History and Start Tracking
|
| 956 |
+
saveCustomJob(result);
|
| 957 |
+
trackJob(result.job_id);
|
| 958 |
+
|
| 959 |
+
} catch (error) {
|
| 960 |
+
showUIState('error', error.message);
|
| 961 |
+
} finally {
|
| 962 |
+
updateUIWithServerStatus();
|
| 963 |
+
}
|
| 964 |
});
|
| 965 |
|
| 966 |
+
createPlayerInstance('audio-player-content-clone');
|
| 967 |
+
showUIState('initial');
|
| 968 |
+
renderHistory();
|
| 969 |
})();
|
| 970 |
|
| 971 |
async function initializeApp() {
|
|
|
|
| 975 |
|
| 976 |
updateSelectedSpeakerDisplay(selectedSpeakerIdStorage.value || speakers[0].id);
|
| 977 |
|
|
|
|
| 978 |
const speakerCardToLock = document.getElementById('selected-speaker-card');
|
| 979 |
if (speakerCardToLock) {
|
|
|
|
| 980 |
setTimeout(() => {
|
| 981 |
const initialWidth = speakerCardToLock.offsetWidth;
|
| 982 |
if (initialWidth > 0) {
|
|
|
|
| 984 |
}
|
| 985 |
}, 100);
|
| 986 |
}
|
|
|
|
| 987 |
|
| 988 |
initializeApp();
|
| 989 |
});
|
| 990 |
</script>
|
| 991 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
| 992 |
</body>
|
| 993 |
</html>
|