Update کد سایت ورود با شماره
Browse files- کد سایت ورود با شماره +521 -224
کد سایت ورود با شماره
CHANGED
|
@@ -6,11 +6,11 @@
|
|
| 6 |
<title>تولید صدای هوشمند با هوش مصنوعی | AI Sada - تبدیل متن به گفتار فارسی</title>
|
| 7 |
<meta name="description" content="با AI Sada، متن فارسی خود را به صدایی طبیعی و با کیفیت استودیویی تبدیل کنید. از میان دهها گوینده حرفهای انتخاب کرده یا صدای خود را شبیهسازی کنید. سریع، آسان و قدرتمند.">
|
| 8 |
<link rel="canonical" href="https://www.aisada.ir/">
|
| 9 |
-
<
|
| 10 |
-
<
|
| 11 |
|
| 12 |
<style>
|
| 13 |
-
|
| 14 |
|
| 15 |
:root {
|
| 16 |
--app-font: 'Vazirmatn', sans-serif; --app-bg: #F8F9FC; --panel-bg: #FFFFFF;
|
|
@@ -474,6 +474,22 @@
|
|
| 474 |
.guide-alert { background: #FFF7ED; border: 1px dashed #FDBA74; padding: 10px; border-radius: 10px; font-size: 0.8rem; display: flex; gap: 8px; margin-bottom: 1rem; color: #9A3412; align-items: flex-start; text-align: right; }
|
| 475 |
#upload-guide-confirm-btn { width: 100%; background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary)); color: white; font-weight: 700; padding: 0.8rem; border-radius: 12px; border: none; cursor: pointer; font-size: 1rem; transition: transform 0.2s; }
|
| 476 |
#upload-guide-confirm-btn:hover { transform: translateY(-2px); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 477 |
</style>
|
| 478 |
</head>
|
| 479 |
<body>
|
|
@@ -483,7 +499,7 @@
|
|
| 483 |
<div id="standard-view">
|
| 484 |
<header class="app-header">
|
| 485 |
<h1>مولد صدای هوشمند Ai صدا</h1>
|
| 486 |
-
<p>کیفیت استودیو، قدرت هوش مصنوعی. متن فارسی را به صدایی طبیعی و با کیفیت استودیویی تبدیل کنید.<br>
|
| 487 |
<div class="header-actions">
|
| 488 |
<div id="user-status-container">
|
| 489 |
<span id="user-email-display" class="user-email" style="direction: ltr;"></span>
|
|
@@ -609,6 +625,24 @@
|
|
| 609 |
<button type="submit" id="send-code-btn" class="generate-btn">ادامه</button>
|
| 610 |
</form>
|
| 611 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 612 |
<!-- فرم تایید شماره تلفن (قشنگ با ویرایش و تایید) -->
|
| 613 |
<form id="code-form" onsubmit="return false;" style="display: none; text-align: center;">
|
| 614 |
<div style="width: 60px; height: 60px; background: rgba(74, 108, 250, 0.1); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--accent-primary); font-size: 1.8rem; margin: 0 auto 1rem auto; animation: bounce 2s infinite;">
|
|
@@ -626,6 +660,17 @@
|
|
| 626 |
<button type="submit" id="verify-code-btn" class="generate-btn" style="flex-grow: 2; padding: 12px; font-weight: 800; background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);">✅ بله، تایید است</button>
|
| 627 |
</div>
|
| 628 |
</form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 629 |
</div>
|
| 630 |
</div>
|
| 631 |
|
|
@@ -711,7 +756,7 @@
|
|
| 711 |
</div>
|
| 712 |
<div class="guide-alert">
|
| 713 |
<span style="font-size: 1.2rem;">⏳</span>
|
| 714 |
-
<span>دقت کنید ساخت
|
| 715 |
</div>
|
| 716 |
<button type="button" id="upload-guide-confirm-btn">اوکی متوجه شدم</button>
|
| 717 |
</div>
|
|
@@ -831,7 +876,7 @@
|
|
| 831 |
|
| 832 |
<section class="contact-section">
|
| 833 |
<h2>پشتیبانی و ارتباط با ما</h2>
|
| 834 |
-
<p>برای سوالات، پیشنهادات یا دریافت پشتیبانی، از طریق تلگرام با ما در ارتباط باشید.</p>
|
| 835 |
<a href="https://t.me/ezmarynoori" target="_blank" rel="noopener noreferrer" class="contact-button">
|
| 836 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M9.78 18.65l.28-4.23 7.68-6.92c.34-.31-.07-.46-.52-.19L7.74 13.3 3.64 12c-.88-.25-.89-.86.2-1.3l15.97-6.16c.73-.33 1.43.18 1.15 1.3l-2.72 12.58c-.28 1.13-1.04 1.4-1.74.88L14.25 16l-2.47 2.35c-.22.24-.42.44-.69.44l.32-4.14z"></path></svg>
|
| 837 |
<span>ارتباط در تلگرام</span>
|
|
@@ -1105,6 +1150,109 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 1105 |
async function checkFreeTierCredit() { if (!currentUser.fingerprint) return; creditStatusMessage.textContent = 'در حال بررسی اعتبار...'; creditStatusMessage.classList.add('visible'); try { const response = await fetch(`${PROXY_URL_BASE}check-credit-tts`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ fingerprint: currentUser.fingerprint, email: currentUser.email }) }); if (!response.ok) throw new Error('Server error during credit check'); const result = await response.json(); if (result.limit_reached) { generationButtons.forEach(btn => btn.disabled = true); creditStatusMessage.textContent = 'اعتبار رایگان روزانه شما تمام شده است.'; pricingSection.scrollIntoView({ behavior: 'smooth' }); } else { generationButtons.forEach(btn => btn.disabled = false); const remaining = result.credits_remaining !== undefined ? result.credits_remaining : 0; creditStatusMessage.textContent = `شما ${remaining} اعتبار رایگان برای امروز دارید.`; } } catch (error) { creditStatusMessage.textContent = 'خطا در بررسی اعتبار.'; generationButtons.forEach(btn => btn.disabled = true); } }
|
| 1106 |
function updateUIForUserState(userData) { currentUser = { ...currentUser, ...userData }; const isLoggedIn = !!currentUser.email; if (isLoggedIn) { localStorage.setItem('userEmail', currentUser.email); userEmailDisplay.textContent = currentUser.email; loginCheckBtn.style.display = 'none'; userStatusContainer.style.display = 'inline-flex'; if (currentUser.status === 'paid') { userSubStatusDisplay.textContent = `اشتراک ویژه تا ${currentUser.expires_at}`; userSubStatusDisplay.className = 'user-sub-status status-paid'; pricingSection.style.display = 'none'; creditStatusMessage.classList.remove('visible'); creditStatusMessage.textContent = ''; generationButtons.forEach(btn => btn.disabled = false); } else { userSubStatusDisplay.textContent = 'کاربر رایگان'; userSubStatusDisplay.className = 'user-sub-status status-free'; pricingSection.style.display = 'block'; checkFreeTierCredit(); } } else { localStorage.removeItem('userEmail'); currentUser.email = null; userStatusContainer.style.display = 'none'; loginCheckBtn.style.display = 'inline-block'; pricingSection.style.display = 'block'; checkFreeTierCredit(); } }
|
| 1107 |
function handleLogout() { fetch(LOGOUT_URL).catch(err => console.error('Logout error:', err)); updateUIForUserState({ status: 'free', email: null, expires_at: null }); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1108 |
|
| 1109 |
// ==================== PART 4.3: PODCAST CORE LOGIC (DB & STATE) ====================
|
| 1110 |
// --- Podcast Logic Start ---
|
|
@@ -1456,7 +1604,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
| 1456 |
قوانین سختگیرانهای که باید رعایت کنی:
|
| 1457 |
۱. فقط و فقط ۲ گوینده (ترجیحاً یک زن و یک مرد) از بین لیست گویندگان در دسترس انتخاب کن. با توجه به متن کاربر گوینده ها میتونه بیشتر از دو نفر مثلا سه یا حد اکثر چهار نفر باشد.
|
| 1458 |
۲. سناریو باید دقیقاً شبیه به یک پادکست واقعی و زنده باشد؛ یعنی گویندگان مدام با هم دیالوگهای کوتاه رد و بدل کنند، از هم سوال بپرسند، صحبتهای یکدیگر را تایید یا تکمیل کنند و با هم شوخی یا صمیمیت پادکستی داشته باشند. به هیچ وجه اجازه نده یکی از گویندگان متنهای خیلی طولانی و خستهکننده به صورت یکطرفه (مونولوگ) بخواند.
|
| 1459 |
-
۳. تمام مفاهیم، نکات و اطلاعات موجود در متن را کاملاً تشریح کن و شاخ و برگ بده تا طول سناریو طولانی و پرمحتوا شود.
|
| 1460 |
|
| 1461 |
موضوع یا متن اصلی برای خلق سناریوی پادکست:
|
| 1462 |
${userText}`;
|
|
@@ -2214,7 +2362,7 @@ ${userText}`;
|
|
| 2214 |
let html = `<input type="radio" name="modal_speaker_selection" value="${speaker.id}" ${isSelected ? 'checked' : ''}><div class="speaker-visual"><img src="${speaker.imgUrl}" alt="${speaker.name}" loading="lazy">${samplesHTML}</div><div class="speaker-name">${speaker.name}</div>`;
|
| 2215 |
|
| 2216 |
if (speaker.isCustom) {
|
| 2217 |
-
html += `<div class="custom-model-badge">ا
|
| 2218 |
if (speaker.audioUrl) { html += `<button type="button" class="model-preview-play-btn" data-audio="${speaker.audioUrl}" title="پیششنوایی صدای مدل"><svg class="play-icon" viewBox="0 0 24 24"><path d="M8 5v14l11-7z"></path></svg><svg class="pause-icon" viewBox="0 0 24 24"><path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"></path></svg></button>`; }
|
| 2219 |
html += `<div class="model-actions"><button type="button" class="model-action-btn btn-edit" title="ویرایش" data-id="${speaker.id}">✎</button><button type="button" class="model-action-btn btn-delete" title="حذف" data-id="${speaker.id}">✕</button></div>`;
|
| 2220 |
}
|
|
@@ -2536,7 +2684,6 @@ ${userText}`;
|
|
| 2536 |
return;
|
| 2537 |
}
|
| 2538 |
|
| 2539 |
-
if (!currentUser.email) { alert('برای تولید صدا، لطفا ابتدا وارد حساب کاربری خود شوید.'); loginCheckBtn.click(); return; }
|
| 2540 |
const text = textInput.value.trim();
|
| 2541 |
if (!text) { showResultState(false, '<b>خطا:</b> متن ورودی خالی است.'); return; }
|
| 2542 |
|
|
@@ -2649,6 +2796,116 @@ ${userText}`;
|
|
| 2649 |
|
| 2650 |
// ==================== PART 4.9: VOICE CLONE & ORCHESTRATION ====================
|
| 2651 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2652 |
(function() {
|
| 2653 |
const form = document.getElementById('voice-clone-form'); if (!form) return;
|
| 2654 |
const generateBtn = form.querySelector('#generate-btn-clone'), btnText = generateBtn.querySelector('.btn-text'), btnSpinner = generateBtn.querySelector('.spinner'), textInput = form.querySelector('#text-input-clone'), promptInput = form.querySelector('#prompt-input-clone'), userVoiceInput = document.getElementById('user-voice-input'), uploadArea = document.getElementById('upload-area'), filePreview = document.getElementById('file-preview'), fileNameSpan = document.getElementById('file-name'), removeFileBtn = document.getElementById('remove-file-btn'), audioPreview = document.getElementById('audio-preview');
|
|
@@ -2683,7 +2940,7 @@ ${userText}`;
|
|
| 2683 |
if (!text.trim() || !lastSelectedFile) { alert("لطفاً هم متن و هم فایل صوتی را وارد کنید."); return; }
|
| 2684 |
|
| 2685 |
showCloneLoading();
|
| 2686 |
-
btnText.textContent = '
|
| 2687 |
|
| 2688 |
const secureToken = generateSecureToken();
|
| 2689 |
window.orchestrateClone(text, lastSelectedFile, secureToken, 1.5, 'clone');
|
|
@@ -2753,55 +3010,74 @@ ${userText}`;
|
|
| 2753 |
statusMessage.style.display = 'none';
|
| 2754 |
outputSection.scrollIntoView({ behavior: 'smooth' });
|
| 2755 |
|
|
|
|
|
|
|
|
|
|
| 2756 |
try {
|
| 2757 |
-
const
|
| 2758 |
-
|
| 2759 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2760 |
|
| 2761 |
-
const
|
| 2762 |
-
|
| 2763 |
-
|
| 2764 |
-
|
| 2765 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2766 |
|
| 2767 |
-
|
| 2768 |
-
|
| 2769 |
-
if(!vcRes.ok) {
|
| 2770 |
-
let errorMessage = 'خطا در آپلود';
|
| 2771 |
let forceLogout = false;
|
| 2772 |
-
|
| 2773 |
try {
|
| 2774 |
-
const
|
| 2775 |
-
if (
|
| 2776 |
-
|
| 2777 |
-
|
| 2778 |
-
|
| 2779 |
-
if(txt) errorMessage = txt;
|
| 2780 |
-
}
|
| 2781 |
-
|
| 2782 |
-
if (forceLogout) {
|
| 2783 |
-
const modal = document.getElementById('session-conflict-modal');
|
| 2784 |
-
if (modal) modal.classList.add('visible');
|
| 2785 |
-
window.deleteJob(tempId);
|
| 2786 |
-
throw new Error("SESSION_CONFLICT");
|
| 2787 |
-
}
|
| 2788 |
-
|
| 2789 |
-
jobData.status = 'failed'; jobData.error = errorMessage; window.saveJob(jobData);
|
| 2790 |
-
throw new Error(errorMessage);
|
| 2791 |
}
|
| 2792 |
|
| 2793 |
-
const
|
| 2794 |
-
|
| 2795 |
-
|
| 2796 |
-
const
|
| 2797 |
-
|
| 2798 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2799 |
statusMessage.innerHTML = `<span style="color:green; font-weight:bold;">✅ درخواست شما ثبت شد. میتوانید صفحه را ببندید، پردازش در سرور ادامه دارد.</span>`;
|
| 2800 |
statusMessage.style.display = 'block';
|
| 2801 |
loadingWrapper.style.display = 'none';
|
| 2802 |
|
|
|
|
|
|
|
| 2803 |
} catch (e) {
|
| 2804 |
-
if (e.message === "SESSION_CONFLICT")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2805 |
console.error(e);
|
| 2806 |
loadingWrapper.style.display = 'none';
|
| 2807 |
statusMessage.innerHTML = `<span style="color:red">خطا: ${e.message}</span>`;
|
|
@@ -2833,7 +3109,7 @@ ${userText}`;
|
|
| 2833 |
const loadingText = loadingWrapper.querySelector('.loading-text');
|
| 2834 |
if(loadingText) {
|
| 2835 |
loadingText.style.display = 'block';
|
| 2836 |
-
loadingText.textContent = 'در حال پ
|
| 2837 |
}
|
| 2838 |
}
|
| 2839 |
|
|
@@ -2843,157 +3119,83 @@ ${userText}`;
|
|
| 2843 |
outputSection.scrollIntoView({ behavior: 'smooth' });
|
| 2844 |
}
|
| 2845 |
|
|
|
|
|
|
|
| 2846 |
try {
|
| 2847 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2848 |
text: text,
|
| 2849 |
-
speaker: 'Charon',
|
| 2850 |
-
temperature: temperature,
|
| 2851 |
email: currentUser.email,
|
| 2852 |
-
fingerprint: currentUser.fingerprint
|
| 2853 |
};
|
| 2854 |
-
|
| 2855 |
-
const
|
| 2856 |
-
method: 'POST',
|
| 2857 |
headers: {
|
| 2858 |
'Content-Type': 'application/json',
|
| 2859 |
'X-App-Auth': secureToken,
|
| 2860 |
'X-CSRF-Token': globalCsrfToken
|
| 2861 |
-
},
|
| 2862 |
-
body: JSON.stringify(
|
| 2863 |
});
|
| 2864 |
|
| 2865 |
-
if (!
|
| 2866 |
-
let errMsg = 'خطا در تولید';
|
| 2867 |
let forceLogout = false;
|
| 2868 |
try {
|
| 2869 |
-
const err = await
|
| 2870 |
-
if(err.
|
| 2871 |
-
if(err.force_logout) forceLogout = true;
|
| 2872 |
} catch(e) {}
|
| 2873 |
-
|
| 2874 |
-
|
| 2875 |
-
const modal = document.getElementById('session-conflict-modal');
|
| 2876 |
-
if(modal) modal.classList.add('visible');
|
| 2877 |
-
throw new Error("SESSION_CONFLICT");
|
| 2878 |
-
}
|
| 2879 |
-
throw new Error(errMsg);
|
| 2880 |
}
|
| 2881 |
|
| 2882 |
-
const
|
| 2883 |
-
|
| 2884 |
-
|
| 2885 |
-
|
| 2886 |
-
|
| 2887 |
-
|
| 2888 |
-
|
| 2889 |
-
|
| 2890 |
-
|
| 2891 |
-
|
| 2892 |
-
|
| 2893 |
-
|
| 2894 |
-
const ttsData = JSON.parse(jsonText);
|
| 2895 |
-
if (ttsData.job_id) { ttsJobId = ttsData.job_id; }
|
| 2896 |
-
else { throw new Error("پاسخ نامعتبر از سرور TTS: " + jsonText); }
|
| 2897 |
-
} catch (e) { throw new Error("خطا در پردازش پاسخ TTS: " + jsonText); }
|
| 2898 |
-
}
|
| 2899 |
-
|
| 2900 |
-
if (!ttsBlob && ttsJobId) {
|
| 2901 |
-
let attempts = 0;
|
| 2902 |
-
const maxAttempts = 60;
|
| 2903 |
-
while(attempts < maxAttempts) {
|
| 2904 |
-
attempts++;
|
| 2905 |
-
await new Promise(r => setTimeout(r, 3000));
|
| 2906 |
-
const pollRes = await fetch(`${PROXY_URL_BASE}check-tts-status`, {
|
| 2907 |
-
method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({job_id: ttsJobId})
|
| 2908 |
-
});
|
| 2909 |
-
|
| 2910 |
-
if (!pollRes.ok) {
|
| 2911 |
-
try {
|
| 2912 |
-
const err = await pollRes.json();
|
| 2913 |
-
if (err.force_logout) {
|
| 2914 |
-
const modal = document.getElementById('session-conflict-modal');
|
| 2915 |
-
if(modal) modal.classList.add('visible');
|
| 2916 |
-
throw new Error("SESSION_CONFLICT");
|
| 2917 |
-
}
|
| 2918 |
-
} catch(e){}
|
| 2919 |
-
}
|
| 2920 |
-
|
| 2921 |
-
const pollBuffer = await pollRes.arrayBuffer();
|
| 2922 |
-
const pollAudioType = getAudioType(pollBuffer);
|
| 2923 |
-
|
| 2924 |
-
if (pollAudioType) {
|
| 2925 |
-
ttsBlob = new Blob([pollBuffer], { type: pollAudioType });
|
| 2926 |
-
break;
|
| 2927 |
-
} else {
|
| 2928 |
-
try {
|
| 2929 |
-
const decoder = new TextDecoder("utf-8");
|
| 2930 |
-
const txt = decoder.decode(pollBuffer);
|
| 2931 |
-
const json = JSON.parse(txt);
|
| 2932 |
-
if (json.status === 'failed') throw new Error('تولید صدای پایه ناموفق بود.');
|
| 2933 |
-
} catch(e) {}
|
| 2934 |
-
}
|
| 2935 |
-
}
|
| 2936 |
-
}
|
| 2937 |
-
if(!ttsBlob) throw new Error('تایماوت: صدای پایه تولید نشد.');
|
| 2938 |
-
|
| 2939 |
-
const tempId = `temp_${Date.now()}`;
|
| 2940 |
-
const jobData = { job_id: tempId, text: text, date: new Date().toLocaleString('fa-IR'), status: 'processing', progress: 10, step_desc: 'ارسال به سرور شبیهسازی...', chunks: [] };
|
| 2941 |
window.saveJob(jobData);
|
| 2942 |
|
| 2943 |
if (loadingWrapper) loadingWrapper.style.display = 'none';
|
| 2944 |
const successMsg = `<span style="color:green; font-weight:bold; display:block; padding:10px; background:#F0FFF4; border:1px solid #C6F6D5; border-radius:10px; text-align:center;">✅ درخواست اختصاصی شما در سابقه ثبت شد و درحال ساخت است با ترک صفحه درخواست از بین نمیرود</span>`;
|
| 2945 |
if (statusMessage) { statusMessage.innerHTML = successMsg; statusMessage.style.display = 'block'; setTimeout(() => { statusMessage.style.display = 'none'; }, 10000); }
|
| 2946 |
|
| 2947 |
-
|
| 2948 |
-
formData.append('email', currentUser.email);
|
| 2949 |
-
formData.append('fingerprint', currentUser.fingerprint);
|
| 2950 |
-
formData.append('source_audio', ttsBlob, 'src.wav');
|
| 2951 |
-
formData.append('ref_audio', file, 'ref.wav');
|
| 2952 |
-
|
| 2953 |
-
const vcRes = await fetch(`${PROXY_URL_BASE}vc-upload`, { method: 'POST', headers: { 'X-App-Auth': generateSecureToken(), 'X-CSRF-Token': globalCsrfToken }, body: formData });
|
| 2954 |
-
|
| 2955 |
-
if(!vcRes.ok) {
|
| 2956 |
-
let errMsg = 'Upload failed';
|
| 2957 |
-
let forceLogout = false;
|
| 2958 |
-
try {
|
| 2959 |
-
const err = await vcRes.json();
|
| 2960 |
-
if(err.message) errMsg = err.message;
|
| 2961 |
-
if(err.force_logout) forceLogout = true;
|
| 2962 |
-
} catch(e){}
|
| 2963 |
-
|
| 2964 |
-
if(forceLogout) {
|
| 2965 |
-
const modal = document.getElementById('session-conflict-modal');
|
| 2966 |
-
if(modal) modal.classList.add('visible');
|
| 2967 |
-
window.deleteJob(tempId);
|
| 2968 |
-
throw new Error("SESSION_CONFLICT");
|
| 2969 |
-
}
|
| 2970 |
-
|
| 2971 |
-
jobData.status = 'failed'; jobData.error = errMsg; window.saveJob(jobData);
|
| 2972 |
-
throw new Error('خطا در آپلود به سرور کلون');
|
| 2973 |
-
}
|
| 2974 |
-
|
| 2975 |
-
const vcData = await vcRes.json();
|
| 2976 |
-
window.deleteJob(tempId);
|
| 2977 |
-
|
| 2978 |
-
const newJobData = { job_id: vcData.job_id, text: text, date: new Date().toLocaleString('fa-IR'), status: 'processing', progress: 15, step_desc: 'شبیهسازی و ترکیب صدا...', total_chunks: vcData.total_chunks, secure_chunks: vcData.secure_chunks, filename: null };
|
| 2979 |
-
window.saveJob(newJobData);
|
| 2980 |
|
| 2981 |
} catch(e) {
|
| 2982 |
-
if (e.message === "SESSION_CONFLICT")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2983 |
console.error(e);
|
| 2984 |
-
if (loadingWrapper
|
| 2985 |
-
|
| 2986 |
-
|
| 2987 |
-
|
| 2988 |
-
statusMessage.innerHTML = `<span style="color:red">خطا: ${e.message}</span>`;
|
| 2989 |
-
}
|
| 2990 |
-
alert(e.message);
|
| 2991 |
}
|
|
|
|
| 2992 |
} finally {
|
| 2993 |
-
|
| 2994 |
-
|
| 2995 |
-
|
| 2996 |
-
|
| 2997 |
}
|
| 2998 |
}
|
| 2999 |
|
|
@@ -3019,74 +3221,159 @@ ${userText}`;
|
|
| 3019 |
if (pendingJobs.length === 0) return;
|
| 3020 |
if (!currentUser.email) return;
|
| 3021 |
|
|
|
|
|
|
|
| 3022 |
for (const job of pendingJobs) {
|
| 3023 |
if (job.job_id.startsWith('temp_')) continue;
|
| 3024 |
-
if (!job.secure_chunks) continue;
|
| 3025 |
|
| 3026 |
-
|
| 3027 |
-
|
| 3028 |
-
|
| 3029 |
-
|
| 3030 |
-
|
| 3031 |
-
|
| 3032 |
-
|
| 3033 |
-
|
|
|
|
| 3034 |
|
| 3035 |
-
|
| 3036 |
-
|
| 3037 |
-
|
| 3038 |
-
|
| 3039 |
-
|
| 3040 |
-
|
| 3041 |
-
|
| 3042 |
-
|
| 3043 |
-
|
| 3044 |
-
|
| 3045 |
-
|
| 3046 |
-
|
| 3047 |
-
|
| 3048 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3049 |
const modal = document.getElementById('session-conflict-modal');
|
| 3050 |
if(modal) modal.classList.add('visible');
|
| 3051 |
-
return;
|
| 3052 |
}
|
| 3053 |
-
|
| 3054 |
-
|
| 3055 |
-
|
| 3056 |
-
const rawText = await response.text();
|
| 3057 |
-
if (!rawText || rawText.trim() === "") continue;
|
| 3058 |
|
| 3059 |
-
|
| 3060 |
-
|
| 3061 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3062 |
|
| 3063 |
-
|
| 3064 |
-
|
| 3065 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3066 |
|
| 3067 |
-
|
| 3068 |
-
|
| 3069 |
-
if (job.status === 'completed') {
|
| 3070 |
-
job.progress = 100;
|
| 3071 |
-
job.step_desc = 'تکمیل شد';
|
| 3072 |
-
} else if (job.status === 'failed') {
|
| 3073 |
-
job.step_desc = 'خطا در سرور: ' + (result.detail || 'نامشخص');
|
| 3074 |
-
} else {
|
| 3075 |
-
job.step_desc = `در حال پردازش قطعات (${backendProgress}%)`;
|
| 3076 |
}
|
| 3077 |
-
|
| 3078 |
-
window.saveJob(job);
|
| 3079 |
-
|
| 3080 |
-
} catch (e) {
|
| 3081 |
-
console.error("Polling error for job " + job.job_id, e);
|
| 3082 |
}
|
| 3083 |
}
|
| 3084 |
}
|
| 3085 |
|
| 3086 |
setInterval(checkPendingJobs, 5000);
|
| 3087 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3088 |
function setupEventListeners() {
|
| 3089 |
-
if(loginCheckBtn) loginCheckBtn.addEventListener('click', () => { showModal(emailModal);
|
| 3090 |
|
| 3091 |
if(logoutBtn) logoutBtn.addEventListener('click', async () => {
|
| 3092 |
if(currentUser.email) {
|
|
@@ -3171,6 +3458,8 @@ ${userText}`;
|
|
| 3171 |
document.getElementById('phone-display-box').textContent = phone;
|
| 3172 |
emailForm.style.display = 'none';
|
| 3173 |
codeForm.style.display = 'block';
|
|
|
|
|
|
|
| 3174 |
});
|
| 3175 |
|
| 3176 |
if(codeForm) codeForm.addEventListener('submit', async (e) => {
|
|
@@ -3190,6 +3479,10 @@ ${userText}`;
|
|
| 3190 |
body: JSON.stringify({ email: phone, fingerprint: stableFingerprint })
|
| 3191 |
});
|
| 3192 |
const result = await response.json();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3193 |
if (!response.ok) throw new Error(result.message || 'خطا در تایید شماره.');
|
| 3194 |
localStorage.setItem('userEmail', phone);
|
| 3195 |
localStorage.setItem('sada_device_fp', stableFingerprint);
|
|
@@ -3197,6 +3490,9 @@ ${userText}`;
|
|
| 3197 |
currentUser.fingerprint = stableFingerprint;
|
| 3198 |
hideModal(emailModal);
|
| 3199 |
await checkUserStatus(phone);
|
|
|
|
|
|
|
|
|
|
| 3200 |
} catch (error) {
|
| 3201 |
alert(error.message);
|
| 3202 |
} finally {
|
|
@@ -3205,7 +3501,7 @@ ${userText}`;
|
|
| 3205 |
}
|
| 3206 |
});
|
| 3207 |
|
| 3208 |
-
if(backToEmailBtn) backToEmailBtn.addEventListener('click', () => {
|
| 3209 |
[changeSpeakerBtn, selectedSpeakerCard].forEach(el => el && el.addEventListener('click', () => { isMainSelectorAction = true; createSpeakerCardsInModal(); showModal(speakerModal); }));
|
| 3210 |
if(backToStandardBtn) backToStandardBtn.addEventListener('click', () => switchView('standard', true));
|
| 3211 |
document.querySelectorAll('.modal-overlay').forEach(o => o.addEventListener('click', (e) => (e.target === o) && hideModal(o)));
|
|
@@ -3270,6 +3566,7 @@ ${userText}`;
|
|
| 3270 |
const userStatusPromise = checkUserStatus(currentUser.email);
|
| 3271 |
|
| 3272 |
setupEventListeners();
|
|
|
|
| 3273 |
|
| 3274 |
await podcastDBPromise;
|
| 3275 |
await mainDBPromise;
|
|
|
|
| 6 |
<title>تولید صدای هوشمند با هوش مصنوعی | AI Sada - تبدیل متن به گفتار فارسی</title>
|
| 7 |
<meta name="description" content="با AI Sada، متن فارسی خود را به صدایی طبیعی و با کیفیت استودیویی تبدیل کنید. از میان دهها گوینده حرفهای انتخاب کرده یا صدای خود را شبیهسازی کنید. سریع، آسان و قدرتمند.">
|
| 8 |
<link rel="canonical" href="https://www.aisada.ir/">
|
| 9 |
+
<meta name="color-scheme" content="light only">
|
| 10 |
+
<script src="https://accounts.google.com/gsi/client?hl=fa" async defer></script>
|
| 11 |
|
| 12 |
<style>
|
| 13 |
+
:root { color-scheme: light only; }
|
| 14 |
|
| 15 |
:root {
|
| 16 |
--app-font: 'Vazirmatn', sans-serif; --app-bg: #F8F9FC; --panel-bg: #FFFFFF;
|
|
|
|
| 474 |
.guide-alert { background: #FFF7ED; border: 1px dashed #FDBA74; padding: 10px; border-radius: 10px; font-size: 0.8rem; display: flex; gap: 8px; margin-bottom: 1rem; color: #9A3412; align-items: flex-start; text-align: right; }
|
| 475 |
#upload-guide-confirm-btn { width: 100%; background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary)); color: white; font-weight: 700; padding: 0.8rem; border-radius: 12px; border: none; cursor: pointer; font-size: 1rem; transition: transform 0.2s; }
|
| 476 |
#upload-guide-confirm-btn:hover { transform: translateY(-2px); }
|
| 477 |
+
|
| 478 |
+
/* [جدید] بلوک قفل موقت ورود بهخاطر پایاندادن مکرر نشست */
|
| 479 |
+
#login-lock-block { text-align: center; padding: 0.5rem 0 1rem 0; animation: fadeIn 0.4s ease-out; }
|
| 480 |
+
.login-lock-icon-wrapper { width: 90px; height: 90px; margin: 0 auto 1.2rem auto; border-radius: 50%; background: linear-gradient(135deg, #FF6B6B, #EE5D88); display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 25px rgba(238, 93, 136, 0.35); animation: pulse-glow-lock 2s infinite; }
|
| 481 |
+
@keyframes pulse-glow-lock { 0% { box-shadow: 0 0 0 0 rgba(238, 93, 136, 0.45); } 70% { box-shadow: 0 0 0 18px rgba(238, 93, 136, 0); } 100% { box-shadow: 0 0 0 0 rgba(238, 93, 136, 0); } }
|
| 482 |
+
.login-lock-icon-wrapper svg { width: 42px; height: 42px; stroke: white; }
|
| 483 |
+
.login-lock-title { font-size: 1.3em; font-weight: 900; margin: 0 0 0.6rem 0; color: var(--text-primary); }
|
| 484 |
+
.login-lock-desc { color: var(--text-secondary); font-size: 0.92em; line-height: 1.8; margin: 0 0 1.5rem 0; padding: 0 0.5rem; }
|
| 485 |
+
.login-lock-countdown { font-size: 2.5em; font-weight: 900; letter-spacing: 2px; font-variant-numeric: tabular-nums; background: linear-gradient(90deg, #EE5D88, #FF6B6B); -webkit-background-clip: text; -webkit-text-fill-color: transparent; direction: ltr; margin-bottom: 0.4rem; }
|
| 486 |
+
.login-lock-subtext { color: var(--text-tertiary); font-size: 0.85em; font-weight: 600; margin: 0; }
|
| 487 |
+
|
| 488 |
+
/* [جدید] دکمه اختصاصی ورود با گوگل (بدون iframe گوگل، برای همترازی درست در RTL) */
|
| 489 |
+
.google-custom-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 0.85rem 1.5rem; background: #fff !important; border: 1px solid var(--input-border); border-radius: 50px; font-family: var(--app-font); font-size: 1rem; font-weight: 600; color: #3c4043 !important; cursor: pointer; transition: var(--transition-smooth); box-shadow: var(--shadow-sm); box-sizing: border-box; }
|
| 490 |
+
.google-custom-btn span { color: #3c4043 !important; }
|
| 491 |
+
.google-custom-btn:hover { background: #f8f9fa; box-shadow: var(--shadow-md); border-color: #c9ccd1; }
|
| 492 |
+
.google-custom-btn:active { background: #f1f3f4; }
|
| 493 |
</style>
|
| 494 |
</head>
|
| 495 |
<body>
|
|
|
|
| 499 |
<div id="standard-view">
|
| 500 |
<header class="app-header">
|
| 501 |
<h1>مولد صدای هوشمند Ai صدا</h1>
|
| 502 |
+
<p>کیفیت استودیو، قدرت هوش مصنوعی. متن فارسی را به صدایی طبیعی و با کیفیت استودیویی تبدیل کنید.<br>Ai Sada</p>
|
| 503 |
<div class="header-actions">
|
| 504 |
<div id="user-status-container">
|
| 505 |
<span id="user-email-display" class="user-email" style="direction: ltr;"></span>
|
|
|
|
| 625 |
<button type="submit" id="send-code-btn" class="generate-btn">ادامه</button>
|
| 626 |
</form>
|
| 627 |
|
| 628 |
+
<!-- ورود سریع با گوگل -->
|
| 629 |
+
<div id="google-signin-block">
|
| 630 |
+
<div style="display:flex; align-items:center; gap:12px; margin: 1.5rem 0 1rem 0;">
|
| 631 |
+
<div style="flex:1; height:1px; background: var(--input-border);"></div>
|
| 632 |
+
<span style="color: var(--text-tertiary); font-size:0.85em; font-weight:700;">یا</span>
|
| 633 |
+
<div style="flex:1; height:1px; background: var(--input-border);"></div>
|
| 634 |
+
</div>
|
| 635 |
+
<button type="button" id="google-signin-btn" class="google-custom-btn">
|
| 636 |
+
<svg width="20" height="20" viewBox="0 0 48 48" style="flex-shrink:0;">
|
| 637 |
+
<path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"/>
|
| 638 |
+
<path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"/>
|
| 639 |
+
<path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"/>
|
| 640 |
+
<path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"/>
|
| 641 |
+
</svg>
|
| 642 |
+
<span>ادامه با گوگل</span>
|
| 643 |
+
</button>
|
| 644 |
+
</div>
|
| 645 |
+
|
| 646 |
<!-- فرم تایید شماره تلفن (قشنگ با ویرایش و تایید) -->
|
| 647 |
<form id="code-form" onsubmit="return false;" style="display: none; text-align: center;">
|
| 648 |
<div style="width: 60px; height: 60px; background: rgba(74, 108, 250, 0.1); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--accent-primary); font-size: 1.8rem; margin: 0 auto 1rem auto; animation: bounce 2s infinite;">
|
|
|
|
| 660 |
<button type="submit" id="verify-code-btn" class="generate-btn" style="flex-grow: 2; padding: 12px; font-weight: 800; background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);">✅ بله، تایید است</button>
|
| 661 |
</div>
|
| 662 |
</form>
|
| 663 |
+
|
| 664 |
+
<!-- [جدید] بلوک قفل موقت ورود بهخاطر پایاندادن مکرر نشست -->
|
| 665 |
+
<div id="login-lock-block" style="display:none;">
|
| 666 |
+
<div class="login-lock-icon-wrapper">
|
| 667 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"></circle><polyline points="12 6 12 12 16 14"></polyline></svg>
|
| 668 |
+
</div>
|
| 669 |
+
<h3 class="login-lock-title">دسترسی موقتاً محدود شده</h3>
|
| 670 |
+
<p class="login-lock-desc">بهخاطر پایاندادن مکرر به نشستها در امروز، امکان ورود برای مدتی محدود شده. لطفاً کمی صبر کنید تا دوباره باز بشه.</p>
|
| 671 |
+
<div class="login-lock-countdown" id="login-lock-countdown-display">۰۰:۰۰:۰۰</div>
|
| 672 |
+
<p class="login-lock-subtext">زمان باقیمانده تا باز شدن دوباره</p>
|
| 673 |
+
</div>
|
| 674 |
</div>
|
| 675 |
</div>
|
| 676 |
|
|
|
|
| 756 |
</div>
|
| 757 |
<div class="guide-alert">
|
| 758 |
<span style="font-size: 1.2rem;">⏳</span>
|
| 759 |
+
<span>دقت کنید فرایند ساخت با صدای اختصاصی زمان بیشتری نیاز دارد. همچنین کیفیت صدای خروجی مدل شما به کیفیت صدای ورودی شما مرتبط است.</span>
|
| 760 |
</div>
|
| 761 |
<button type="button" id="upload-guide-confirm-btn">اوکی متوجه شدم</button>
|
| 762 |
</div>
|
|
|
|
| 876 |
|
| 877 |
<section class="contact-section">
|
| 878 |
<h2>پشتیبانی و ارتباط با ما</h2>
|
| 879 |
+
<p>برای سوالات، پیشنهادات یا دریافت پشتیبانی، از طریق تلگرام با ما در ارتباط باشید. همچنین آیدی پشتیبانی در روبیکا@aialpha_admin</p>
|
| 880 |
<a href="https://t.me/ezmarynoori" target="_blank" rel="noopener noreferrer" class="contact-button">
|
| 881 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M9.78 18.65l.28-4.23 7.68-6.92c.34-.31-.07-.46-.52-.19L7.74 13.3 3.64 12c-.88-.25-.89-.86.2-1.3l15.97-6.16c.73-.33 1.43.18 1.15 1.3l-2.72 12.58c-.28 1.13-1.04 1.4-1.74.88L14.25 16l-2.47 2.35c-.22.24-.42.44-.69.44l.32-4.14z"></path></svg>
|
| 882 |
<span>ارتباط در تلگرام</span>
|
|
|
|
| 1150 |
async function checkFreeTierCredit() { if (!currentUser.fingerprint) return; creditStatusMessage.textContent = 'در حال بررسی اعتبار...'; creditStatusMessage.classList.add('visible'); try { const response = await fetch(`${PROXY_URL_BASE}check-credit-tts`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ fingerprint: currentUser.fingerprint, email: currentUser.email }) }); if (!response.ok) throw new Error('Server error during credit check'); const result = await response.json(); if (result.limit_reached) { generationButtons.forEach(btn => btn.disabled = true); creditStatusMessage.textContent = 'اعتبار رایگان روزانه شما تمام شده است.'; pricingSection.scrollIntoView({ behavior: 'smooth' }); } else { generationButtons.forEach(btn => btn.disabled = false); const remaining = result.credits_remaining !== undefined ? result.credits_remaining : 0; creditStatusMessage.textContent = `شما ${remaining} اعتبار رایگان برای امروز دارید.`; } } catch (error) { creditStatusMessage.textContent = 'خطا در بررسی اعتبار.'; generationButtons.forEach(btn => btn.disabled = true); } }
|
| 1151 |
function updateUIForUserState(userData) { currentUser = { ...currentUser, ...userData }; const isLoggedIn = !!currentUser.email; if (isLoggedIn) { localStorage.setItem('userEmail', currentUser.email); userEmailDisplay.textContent = currentUser.email; loginCheckBtn.style.display = 'none'; userStatusContainer.style.display = 'inline-flex'; if (currentUser.status === 'paid') { userSubStatusDisplay.textContent = `اشتراک ویژه تا ${currentUser.expires_at}`; userSubStatusDisplay.className = 'user-sub-status status-paid'; pricingSection.style.display = 'none'; creditStatusMessage.classList.remove('visible'); creditStatusMessage.textContent = ''; generationButtons.forEach(btn => btn.disabled = false); } else { userSubStatusDisplay.textContent = 'کاربر رایگان'; userSubStatusDisplay.className = 'user-sub-status status-free'; pricingSection.style.display = 'block'; checkFreeTierCredit(); } } else { localStorage.removeItem('userEmail'); currentUser.email = null; userStatusContainer.style.display = 'none'; loginCheckBtn.style.display = 'inline-block'; pricingSection.style.display = 'block'; checkFreeTierCredit(); } }
|
| 1152 |
function handleLogout() { fetch(LOGOUT_URL).catch(err => console.error('Logout error:', err)); updateUIForUserState({ status: 'free', email: null, expires_at: null }); }
|
| 1153 |
+
|
| 1154 |
+
// ---- Google Sign-In ----
|
| 1155 |
+
const GOOGLE_CLIENT_ID = '984805835853-fhfju0au5qbojet3hjo07t9fqsbupg5n.apps.googleusercontent.com';
|
| 1156 |
+
let googleTokenClient = null;
|
| 1157 |
+
|
| 1158 |
+
function handleGoogleTokenResponse(tokenResponse) {
|
| 1159 |
+
(async () => {
|
| 1160 |
+
const googleBtn = document.getElementById('google-signin-btn');
|
| 1161 |
+
try {
|
| 1162 |
+
if (!tokenResponse || tokenResponse.error || !tokenResponse.access_token) {
|
| 1163 |
+
return; // کاربر پنجره گوگل رو بسته یا لغو کرده؛ نیازی به نمایش خطا نیست
|
| 1164 |
+
}
|
| 1165 |
+
if (googleBtn) { googleBtn.disabled = true; googleBtn.style.opacity = '0.6'; }
|
| 1166 |
+
const stableFingerprint = await getStableFingerprint();
|
| 1167 |
+
const res = await fetch(`${PROXY_URL_BASE}google-verify`, {
|
| 1168 |
+
method: 'POST',
|
| 1169 |
+
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': globalCsrfToken },
|
| 1170 |
+
body: JSON.stringify({ access_token: tokenResponse.access_token, fingerprint: stableFingerprint })
|
| 1171 |
+
});
|
| 1172 |
+
const result = await res.json();
|
| 1173 |
+
if (res.status === 429 && result.locked) {
|
| 1174 |
+
showLoginLockCountdown(result.locked_until);
|
| 1175 |
+
return;
|
| 1176 |
+
}
|
| 1177 |
+
if (!res.ok) throw new Error(result.message || 'خطا در ورود با گوگل.');
|
| 1178 |
+
|
| 1179 |
+
localStorage.setItem('userEmail', result.email);
|
| 1180 |
+
localStorage.setItem('sada_device_fp', stableFingerprint);
|
| 1181 |
+
currentUser.email = result.email;
|
| 1182 |
+
currentUser.fingerprint = stableFingerprint;
|
| 1183 |
+
|
| 1184 |
+
hideModal(emailModal);
|
| 1185 |
+
await checkUserStatus(result.email);
|
| 1186 |
+
if (result.previous_session_ended) {
|
| 1187 |
+
setTimeout(() => alert('توجه: این حساب روی دستگاه دیگری هم فعال بود؛ نشست قبلی بسته شد و از این پس همین دستگاه فعاله.'), 400);
|
| 1188 |
+
}
|
| 1189 |
+
} catch (error) {
|
| 1190 |
+
alert(error.message || 'ورود با گوگل ناموفق بود. لطفا دوباره تلاش کنید.');
|
| 1191 |
+
} finally {
|
| 1192 |
+
if (googleBtn) { googleBtn.disabled = false; googleBtn.style.opacity = '1'; }
|
| 1193 |
+
}
|
| 1194 |
+
})();
|
| 1195 |
+
}
|
| 1196 |
+
|
| 1197 |
+
function initGoogleSignIn() {
|
| 1198 |
+
const btn = document.getElementById('google-signin-btn');
|
| 1199 |
+
if (!btn) return;
|
| 1200 |
+
if (!window.google || !window.google.accounts || !window.google.accounts.oauth2) {
|
| 1201 |
+
setTimeout(initGoogleSignIn, 300);
|
| 1202 |
+
return;
|
| 1203 |
+
}
|
| 1204 |
+
googleTokenClient = google.accounts.oauth2.initTokenClient({
|
| 1205 |
+
client_id: GOOGLE_CLIENT_ID,
|
| 1206 |
+
scope: 'email profile',
|
| 1207 |
+
callback: handleGoogleTokenResponse
|
| 1208 |
+
});
|
| 1209 |
+
btn.addEventListener('click', () => {
|
| 1210 |
+
if (googleTokenClient) googleTokenClient.requestAccessToken();
|
| 1211 |
+
});
|
| 1212 |
+
}
|
| 1213 |
+
|
| 1214 |
+
// ---- تایمر شمارش معکوس قفل موقت ورود ----
|
| 1215 |
+
let loginLockInterval = null;
|
| 1216 |
+
|
| 1217 |
+
function showLoginLockCountdown(lockedUntilSeconds) {
|
| 1218 |
+
if (loginLockInterval) { clearInterval(loginLockInterval); loginLockInterval = null; }
|
| 1219 |
+
|
| 1220 |
+
if (emailForm) emailForm.style.display = 'none';
|
| 1221 |
+
if (codeForm) codeForm.style.display = 'none';
|
| 1222 |
+
const googleBlock = document.getElementById('google-signin-block');
|
| 1223 |
+
if (googleBlock) googleBlock.style.display = 'none';
|
| 1224 |
+
|
| 1225 |
+
const lockBlock = document.getElementById('login-lock-block');
|
| 1226 |
+
const display = document.getElementById('login-lock-countdown-display');
|
| 1227 |
+
if (!lockBlock || !display) return;
|
| 1228 |
+
lockBlock.style.display = 'block';
|
| 1229 |
+
|
| 1230 |
+
const tick = () => {
|
| 1231 |
+
const remaining = lockedUntilSeconds - Math.floor(Date.now() / 1000);
|
| 1232 |
+
if (remaining <= 0) {
|
| 1233 |
+
hideLoginLockCountdown();
|
| 1234 |
+
return;
|
| 1235 |
+
}
|
| 1236 |
+
const h = Math.floor(remaining / 3600);
|
| 1237 |
+
const m = Math.floor((remaining % 3600) / 60);
|
| 1238 |
+
const s = remaining % 60;
|
| 1239 |
+
display.textContent = `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}:${String(s).padStart(2, '0')}`;
|
| 1240 |
+
};
|
| 1241 |
+
|
| 1242 |
+
tick();
|
| 1243 |
+
loginLockInterval = setInterval(tick, 1000);
|
| 1244 |
+
}
|
| 1245 |
+
|
| 1246 |
+
function hideLoginLockCountdown() {
|
| 1247 |
+
if (loginLockInterval) { clearInterval(loginLockInterval); loginLockInterval = null; }
|
| 1248 |
+
const lockBlock = document.getElementById('login-lock-block');
|
| 1249 |
+
if (lockBlock) lockBlock.style.display = 'none';
|
| 1250 |
+
if (emailForm) emailForm.style.display = 'block';
|
| 1251 |
+
if (codeForm) codeForm.style.display = 'none';
|
| 1252 |
+
const googleBlock = document.getElementById('google-signin-block');
|
| 1253 |
+
if (googleBlock) googleBlock.style.display = 'block';
|
| 1254 |
+
if (loginEmailInput) loginEmailInput.value = '';
|
| 1255 |
+
}
|
| 1256 |
|
| 1257 |
// ==================== PART 4.3: PODCAST CORE LOGIC (DB & STATE) ====================
|
| 1258 |
// --- Podcast Logic Start ---
|
|
|
|
| 1604 |
قوانین سختگیرانهای که باید رعایت کنی:
|
| 1605 |
۱. فقط و فقط ۲ گوینده (ترجیحاً یک زن و یک مرد) از بین لیست گویندگان در دسترس انتخاب کن. با توجه به متن کاربر گوینده ها میتونه بیشتر از دو نفر مثلا سه یا حد اکثر چهار نفر باشد.
|
| 1606 |
۲. سناریو باید دقیقاً شبیه به یک پادکست واقعی و زنده باشد؛ یعنی گویندگان مدام با هم دیالوگهای کوتاه رد و بدل کنند، از هم سوال بپرسند، صحبتهای یکدیگر را تایید یا تکمیل کنند و با هم شوخی یا صمیمیت پادکستی داشته باشند. به هیچ وجه اجازه نده یکی از گویندگان متنهای خیلی طولانی و خستهکننده به صورت یکطرفه (مونولوگ) بخواند.
|
| 1607 |
+
۳. تمام مفاهیم، نکات و اطلاعات موجود در متن را کاملاً تشریح کن و شاخ و برگ بده تا طول سناریو طولانی و پرمحتوا شود. و حتما از اسم های اصیل فارسی برای گوینده ها استفاده کن.
|
| 1608 |
|
| 1609 |
موضوع یا متن اصلی برای خلق سناریوی پادکست:
|
| 1610 |
${userText}`;
|
|
|
|
| 2362 |
let html = `<input type="radio" name="modal_speaker_selection" value="${speaker.id}" ${isSelected ? 'checked' : ''}><div class="speaker-visual"><img src="${speaker.imgUrl}" alt="${speaker.name}" loading="lazy">${samplesHTML}</div><div class="speaker-name">${speaker.name}</div>`;
|
| 2363 |
|
| 2364 |
if (speaker.isCustom) {
|
| 2365 |
+
html += `<div class="custom-model-badge">اختصاصی</div>`;
|
| 2366 |
if (speaker.audioUrl) { html += `<button type="button" class="model-preview-play-btn" data-audio="${speaker.audioUrl}" title="پیششنوایی صدای مدل"><svg class="play-icon" viewBox="0 0 24 24"><path d="M8 5v14l11-7z"></path></svg><svg class="pause-icon" viewBox="0 0 24 24"><path d="M6 19h4V5H6v14zm8-14v14h4V5h-4z"></path></svg></button>`; }
|
| 2367 |
html += `<div class="model-actions"><button type="button" class="model-action-btn btn-edit" title="ویرایش" data-id="${speaker.id}">✎</button><button type="button" class="model-action-btn btn-delete" title="حذف" data-id="${speaker.id}">✕</button></div>`;
|
| 2368 |
}
|
|
|
|
| 2684 |
return;
|
| 2685 |
}
|
| 2686 |
|
|
|
|
| 2687 |
const text = textInput.value.trim();
|
| 2688 |
if (!text) { showResultState(false, '<b>خطا:</b> متن ورودی خالی است.'); return; }
|
| 2689 |
|
|
|
|
| 2796 |
|
| 2797 |
// ==================== PART 4.9: VOICE CLONE & ORCHESTRATION ====================
|
| 2798 |
|
| 2799 |
+
async function uploadFileToProxy(file, runId, suffix, secureToken) {
|
| 2800 |
+
const formData = new FormData();
|
| 2801 |
+
|
| 2802 |
+
// رفع خطای Cannot read properties of undefined (reading 'split')
|
| 2803 |
+
// پشتیبانی از فایلهای فیزیکی (دارای name) و بلابهای دیتابیس (بدون name)
|
| 2804 |
+
let ext = 'wav';
|
| 2805 |
+
if (file && file.name) {
|
| 2806 |
+
ext = file.name.split('.').pop().toLowerCase();
|
| 2807 |
+
} else if (file && file.type) {
|
| 2808 |
+
ext = file.type.split('/')[1] || 'wav';
|
| 2809 |
+
if (ext === 'mpeg' || ext === 'mpga') ext = 'mp3';
|
| 2810 |
+
if (ext.includes(';')) ext = ext.split(';')[0];
|
| 2811 |
+
}
|
| 2812 |
+
|
| 2813 |
+
const fileName = (file && file.name) ? file.name : `voice_ref.${ext}`;
|
| 2814 |
+
|
| 2815 |
+
formData.append('run_id', `${runId}_${suffix}`);
|
| 2816 |
+
formData.append('ext', ext);
|
| 2817 |
+
formData.append('file', file, fileName);
|
| 2818 |
+
formData.append('email', currentUser.email);
|
| 2819 |
+
formData.append('fingerprint', currentUser.fingerprint);
|
| 2820 |
+
|
| 2821 |
+
const response = await fetch(`${PROXY_URL_BASE}webhook-upload`, {
|
| 2822 |
+
method: 'POST',
|
| 2823 |
+
headers: {
|
| 2824 |
+
'X-App-Auth': secureToken,
|
| 2825 |
+
'X-CSRF-Token': globalCsrfToken
|
| 2826 |
+
},
|
| 2827 |
+
body: formData
|
| 2828 |
+
});
|
| 2829 |
+
if (!response.ok) {
|
| 2830 |
+
if (response.status === 401) throw new Error("SESSION_CONFLICT");
|
| 2831 |
+
throw new Error("خطا در آپلود فایل");
|
| 2832 |
+
}
|
| 2833 |
+
return ext;
|
| 2834 |
+
}
|
| 2835 |
+
|
| 2836 |
+
function safeBase64Encode(str) {
|
| 2837 |
+
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => {
|
| 2838 |
+
return String.fromCharCode('0x' + p1);
|
| 2839 |
+
}));
|
| 2840 |
+
}
|
| 2841 |
+
|
| 2842 |
+
function pollActionStatus(runId) {
|
| 2843 |
+
const secureToken = generateSecureToken();
|
| 2844 |
+
const poll = setInterval(async () => {
|
| 2845 |
+
try {
|
| 2846 |
+
const response = await fetch(`${PROXY_URL_BASE}check-action-status&run_id=${runId}`, {
|
| 2847 |
+
method: 'POST',
|
| 2848 |
+
headers: {
|
| 2849 |
+
'Content-Type': 'application/json',
|
| 2850 |
+
'X-App-Auth': secureToken,
|
| 2851 |
+
'X-CSRF-Token': globalCsrfToken
|
| 2852 |
+
},
|
| 2853 |
+
body: JSON.stringify({ email: currentUser.email, fingerprint: currentUser.fingerprint })
|
| 2854 |
+
});
|
| 2855 |
+
|
| 2856 |
+
if (!response.ok) {
|
| 2857 |
+
if (response.status === 401) {
|
| 2858 |
+
clearInterval(poll);
|
| 2859 |
+
const modal = document.getElementById('session-conflict-modal');
|
| 2860 |
+
if(modal) modal.classList.add('visible');
|
| 2861 |
+
}
|
| 2862 |
+
return;
|
| 2863 |
+
}
|
| 2864 |
+
|
| 2865 |
+
const statusData = await response.json();
|
| 2866 |
+
const jobs = window.getJobs();
|
| 2867 |
+
const job = jobs[runId];
|
| 2868 |
+
if (!job) {
|
| 2869 |
+
clearInterval(poll);
|
| 2870 |
+
return;
|
| 2871 |
+
}
|
| 2872 |
+
|
| 2873 |
+
if (statusData.status === 'ready') {
|
| 2874 |
+
const fileUrlLower = statusData.url.toLowerCase();
|
| 2875 |
+
|
| 2876 |
+
// بررسی ایمنی: اگر فایل آماده شده در واقع کارت خطای تصویری اکشنز باشد!
|
| 2877 |
+
if (fileUrlLower.endsWith('.png') || fileUrlLower.endsWith('.jpg') || fileUrlLower.endsWith('.jpeg') || fileUrlLower.endsWith('.txt')) {
|
| 2878 |
+
clearInterval(poll);
|
| 2879 |
+
job.status = 'failed';
|
| 2880 |
+
job.error = 'پردازش ابری متوقف شد (احتمالاً سهمیه سرور پردازشگر موقتاً پر شده است).';
|
| 2881 |
+
window.saveJob(job);
|
| 2882 |
+
return;
|
| 2883 |
+
}
|
| 2884 |
+
|
| 2885 |
+
clearInterval(poll);
|
| 2886 |
+
job.status = 'completed';
|
| 2887 |
+
job.progress = 100;
|
| 2888 |
+
job.step_desc = 'تکمیل شد';
|
| 2889 |
+
|
| 2890 |
+
job.filename = statusData.url;
|
| 2891 |
+
window.saveJob(job);
|
| 2892 |
+
} else if (statusData.status === 'failed') {
|
| 2893 |
+
clearInterval(poll);
|
| 2894 |
+
job.status = 'failed';
|
| 2895 |
+
job.error = statusData.message || 'خطا در عملیات سیستمی';
|
| 2896 |
+
window.saveJob(job);
|
| 2897 |
+
} else {
|
| 2898 |
+
job.progress = Math.min(95, (job.progress || 20) + 5);
|
| 2899 |
+
job.step_desc = 'در حال انجام فرآیند ابری...';
|
| 2900 |
+
window.saveJob(job);
|
| 2901 |
+
}
|
| 2902 |
+
|
| 2903 |
+
} catch (e) {
|
| 2904 |
+
console.error('Polling error', e);
|
| 2905 |
+
}
|
| 2906 |
+
}, 5000);
|
| 2907 |
+
}
|
| 2908 |
+
|
| 2909 |
(function() {
|
| 2910 |
const form = document.getElementById('voice-clone-form'); if (!form) return;
|
| 2911 |
const generateBtn = form.querySelector('#generate-btn-clone'), btnText = generateBtn.querySelector('.btn-text'), btnSpinner = generateBtn.querySelector('.spinner'), textInput = form.querySelector('#text-input-clone'), promptInput = form.querySelector('#prompt-input-clone'), userVoiceInput = document.getElementById('user-voice-input'), uploadArea = document.getElementById('upload-area'), filePreview = document.getElementById('file-preview'), fileNameSpan = document.getElementById('file-name'), removeFileBtn = document.getElementById('remove-file-btn'), audioPreview = document.getElementById('audio-preview');
|
|
|
|
| 2940 |
if (!text.trim() || !lastSelectedFile) { alert("لطفاً هم متن و هم فایل صوتی را وارد کنید."); return; }
|
| 2941 |
|
| 2942 |
showCloneLoading();
|
| 2943 |
+
btnText.textContent = 'آمادهسازی ساختار فایلها...';
|
| 2944 |
|
| 2945 |
const secureToken = generateSecureToken();
|
| 2946 |
window.orchestrateClone(text, lastSelectedFile, secureToken, 1.5, 'clone');
|
|
|
|
| 3010 |
statusMessage.style.display = 'none';
|
| 3011 |
outputSection.scrollIntoView({ behavior: 'smooth' });
|
| 3012 |
|
| 3013 |
+
const secureToken = generateSecureToken();
|
| 3014 |
+
const currentRunId = "vev" + Math.random().toString(36).substring(2, 14);
|
| 3015 |
+
|
| 3016 |
try {
|
| 3017 |
+
const loadingText = loadingWrapper.querySelector('.loading-text');
|
| 3018 |
+
if(loadingText) loadingText.textContent = 'آپلود فایل صوتی ورودی...';
|
| 3019 |
+
const sourceExt = await uploadFileToProxy(sourceFile, currentRunId, 'vevo_source', secureToken);
|
| 3020 |
+
|
| 3021 |
+
if(loadingText) loadingText.textContent = 'آپلود فایل صوتی الگو...';
|
| 3022 |
+
const refExt = await uploadFileToProxy(targetFile, currentRunId, 'vevo_ref', secureToken);
|
| 3023 |
+
|
| 3024 |
+
if(loadingText) loadingText.textContent = 'ثبت نوبت در سرور ابری...';
|
| 3025 |
+
|
| 3026 |
+
const payload = {
|
| 3027 |
+
action_name: 'vevo-voice',
|
| 3028 |
+
run_id: currentRunId,
|
| 3029 |
+
sourceExt: sourceExt,
|
| 3030 |
+
refExt: refExt,
|
| 3031 |
+
email: currentUser.email,
|
| 3032 |
+
fingerprint: currentUser.fingerprint
|
| 3033 |
+
};
|
| 3034 |
|
| 3035 |
+
const response = await fetch(`${PROXY_URL_BASE}generate`, {
|
| 3036 |
+
method: 'POST',
|
| 3037 |
+
headers: {
|
| 3038 |
+
'Content-Type': 'application/json',
|
| 3039 |
+
'X-App-Auth': secureToken,
|
| 3040 |
+
'X-CSRF-Token': globalCsrfToken
|
| 3041 |
+
},
|
| 3042 |
+
body: JSON.stringify(payload)
|
| 3043 |
+
});
|
| 3044 |
|
| 3045 |
+
if (!response.ok) {
|
|
|
|
|
|
|
|
|
|
| 3046 |
let forceLogout = false;
|
|
|
|
| 3047 |
try {
|
| 3048 |
+
const err = await response.json();
|
| 3049 |
+
if (err.force_logout) forceLogout = true;
|
| 3050 |
+
} catch(e) {}
|
| 3051 |
+
if (forceLogout) throw new Error("SESSION_CONFLICT");
|
| 3052 |
+
throw new Error('خطا در ثبت نوبت صف');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3053 |
}
|
| 3054 |
|
| 3055 |
+
const data = await response.json();
|
| 3056 |
+
const run_id = data.run_id || currentRunId;
|
| 3057 |
+
|
| 3058 |
+
const jobData = {
|
| 3059 |
+
job_id: run_id,
|
| 3060 |
+
text: 'کلون صدا (V2V) - ' + (sourceFile.name || 'آپلود شده'),
|
| 3061 |
+
date: new Date().toLocaleString('fa-IR'),
|
| 3062 |
+
status: 'processing',
|
| 3063 |
+
progress: 20,
|
| 3064 |
+
step_desc: 'در حال پردازش هوشمند در سرور...',
|
| 3065 |
+
filename: null
|
| 3066 |
+
};
|
| 3067 |
+
window.saveJob(jobData);
|
| 3068 |
+
|
| 3069 |
statusMessage.innerHTML = `<span style="color:green; font-weight:bold;">✅ درخواست شما ثبت شد. میتوانید صفحه را ببندید، پردازش در سرور ادامه دارد.</span>`;
|
| 3070 |
statusMessage.style.display = 'block';
|
| 3071 |
loadingWrapper.style.display = 'none';
|
| 3072 |
|
| 3073 |
+
pollActionStatus(run_id);
|
| 3074 |
+
|
| 3075 |
} catch (e) {
|
| 3076 |
+
if (e.message === "SESSION_CONFLICT") {
|
| 3077 |
+
const modal = document.getElementById('session-conflict-modal');
|
| 3078 |
+
if (modal) modal.classList.add('visible');
|
| 3079 |
+
return;
|
| 3080 |
+
}
|
| 3081 |
console.error(e);
|
| 3082 |
loadingWrapper.style.display = 'none';
|
| 3083 |
statusMessage.innerHTML = `<span style="color:red">خطا: ${e.message}</span>`;
|
|
|
|
| 3109 |
const loadingText = loadingWrapper.querySelector('.loading-text');
|
| 3110 |
if(loadingText) {
|
| 3111 |
loadingText.style.display = 'block';
|
| 3112 |
+
loadingText.textContent = 'در حال آپلود و آمادهسازی مرجع...';
|
| 3113 |
}
|
| 3114 |
}
|
| 3115 |
|
|
|
|
| 3119 |
outputSection.scrollIntoView({ behavior: 'smooth' });
|
| 3120 |
}
|
| 3121 |
|
| 3122 |
+
const currentRunId = 'voice' + Math.random().toString(36).substring(2, 14);
|
| 3123 |
+
|
| 3124 |
try {
|
| 3125 |
+
const audExt = await uploadFileToProxy(file, currentRunId, 'voice_ref', secureToken);
|
| 3126 |
+
|
| 3127 |
+
if (loadingWrapper) {
|
| 3128 |
+
const loadingText = loadingWrapper.querySelector('.loading-text');
|
| 3129 |
+
if(loadingText) loadingText.textContent = 'ارسال به صف پردازش اختصاصی...';
|
| 3130 |
+
}
|
| 3131 |
+
|
| 3132 |
+
const payload = {
|
| 3133 |
+
action_name: 'shabihsazi-sada',
|
| 3134 |
+
run_id: currentRunId,
|
| 3135 |
+
audExt: audExt,
|
| 3136 |
text: text,
|
|
|
|
|
|
|
| 3137 |
email: currentUser.email,
|
| 3138 |
+
fingerprint: currentUser.fingerprint
|
| 3139 |
};
|
| 3140 |
+
|
| 3141 |
+
const response = await fetch(`${PROXY_URL_BASE}generate`, {
|
| 3142 |
+
method: 'POST',
|
| 3143 |
headers: {
|
| 3144 |
'Content-Type': 'application/json',
|
| 3145 |
'X-App-Auth': secureToken,
|
| 3146 |
'X-CSRF-Token': globalCsrfToken
|
| 3147 |
+
},
|
| 3148 |
+
body: JSON.stringify(payload)
|
| 3149 |
});
|
| 3150 |
|
| 3151 |
+
if (!response.ok) {
|
|
|
|
| 3152 |
let forceLogout = false;
|
| 3153 |
try {
|
| 3154 |
+
const err = await response.json();
|
| 3155 |
+
if (err.force_logout) forceLogout = true;
|
|
|
|
| 3156 |
} catch(e) {}
|
| 3157 |
+
if (forceLogout) throw new Error("SESSION_CONFLICT");
|
| 3158 |
+
throw new Error('خطا در ثبت نوبت صف');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3159 |
}
|
| 3160 |
|
| 3161 |
+
const data = await response.json();
|
| 3162 |
+
const run_id = data.run_id || currentRunId;
|
| 3163 |
+
|
| 3164 |
+
const jobData = {
|
| 3165 |
+
job_id: run_id,
|
| 3166 |
+
text: text,
|
| 3167 |
+
date: new Date().toLocaleString('fa-IR'),
|
| 3168 |
+
status: 'processing',
|
| 3169 |
+
progress: 20,
|
| 3170 |
+
step_desc: 'شبیهسازی صدا در سرورهای ابری...',
|
| 3171 |
+
filename: null
|
| 3172 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3173 |
window.saveJob(jobData);
|
| 3174 |
|
| 3175 |
if (loadingWrapper) loadingWrapper.style.display = 'none';
|
| 3176 |
const successMsg = `<span style="color:green; font-weight:bold; display:block; padding:10px; background:#F0FFF4; border:1px solid #C6F6D5; border-radius:10px; text-align:center;">✅ درخواست اختصاصی شما در سابقه ثبت شد و درحال ساخت است با ترک صفحه درخواست از بین نمیرود</span>`;
|
| 3177 |
if (statusMessage) { statusMessage.innerHTML = successMsg; statusMessage.style.display = 'block'; setTimeout(() => { statusMessage.style.display = 'none'; }, 10000); }
|
| 3178 |
|
| 3179 |
+
pollActionStatus(run_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3180 |
|
| 3181 |
} catch(e) {
|
| 3182 |
+
if (e.message === "SESSION_CONFLICT") {
|
| 3183 |
+
const modal = document.getElementById('session-conflict-modal');
|
| 3184 |
+
if(modal) modal.classList.add('visible');
|
| 3185 |
+
return;
|
| 3186 |
+
}
|
| 3187 |
console.error(e);
|
| 3188 |
+
if (loadingWrapper) loadingWrapper.style.display = 'none';
|
| 3189 |
+
if (statusMessage) {
|
| 3190 |
+
statusMessage.style.display = 'block';
|
| 3191 |
+
statusMessage.innerHTML = `<span style="color:red">خطا: ${e.message}</span>`;
|
|
|
|
|
|
|
|
|
|
| 3192 |
}
|
| 3193 |
+
alert(e.message);
|
| 3194 |
} finally {
|
| 3195 |
+
const generateBtn = document.getElementById('generate-btn-clone');
|
| 3196 |
+
const standardGenerateBtn = document.getElementById('generate-btn-standard');
|
| 3197 |
+
if (generateBtn) { generateBtn.disabled = false; const btnTxtClone = generateBtn.querySelector('.btn-text'); if(btnTxtClone) btnTxtClone.textContent = 'ارسال به صف پردازش'; }
|
| 3198 |
+
if (standardGenerateBtn) { standardGenerateBtn.disabled = false; const stdBtnText = standardGenerateBtn.querySelector('.btn-text'); if(stdBtnText) stdBtnText.textContent = '✨ خلق صدا با آلفا'; const stdSpinner = standardGenerateBtn.querySelector('.spinner'); if(stdSpinner) stdSpinner.style.display = 'none'; }
|
| 3199 |
}
|
| 3200 |
}
|
| 3201 |
|
|
|
|
| 3221 |
if (pendingJobs.length === 0) return;
|
| 3222 |
if (!currentUser.email) return;
|
| 3223 |
|
| 3224 |
+
const secureToken = generateSecureToken();
|
| 3225 |
+
|
| 3226 |
for (const job of pendingJobs) {
|
| 3227 |
if (job.job_id.startsWith('temp_')) continue;
|
|
|
|
| 3228 |
|
| 3229 |
+
if (job.secure_chunks) {
|
| 3230 |
+
try {
|
| 3231 |
+
const payload = {
|
| 3232 |
+
job_id: job.job_id,
|
| 3233 |
+
total_chunks: job.total_chunks,
|
| 3234 |
+
secure_chunks: job.secure_chunks,
|
| 3235 |
+
email: currentUser.email,
|
| 3236 |
+
fingerprint: currentUser.fingerprint
|
| 3237 |
+
};
|
| 3238 |
|
| 3239 |
+
const response = await fetch(`${PROXY_URL_BASE}vc-status`, {
|
| 3240 |
+
method: 'POST',
|
| 3241 |
+
headers: {
|
| 3242 |
+
'Content-Type': 'application/json',
|
| 3243 |
+
'X-App-Auth': secureToken,
|
| 3244 |
+
'X-CSRF-Token': globalCsrfToken
|
| 3245 |
+
},
|
| 3246 |
+
body: JSON.stringify(payload)
|
| 3247 |
+
});
|
| 3248 |
+
|
| 3249 |
+
if (response.status === 401) {
|
| 3250 |
+
try {
|
| 3251 |
+
const err = await response.json();
|
| 3252 |
+
if (err.force_logout) {
|
| 3253 |
+
const modal = document.getElementById('session-conflict-modal');
|
| 3254 |
+
if(modal) modal.classList.add('visible');
|
| 3255 |
+
return;
|
| 3256 |
+
}
|
| 3257 |
+
} catch(e){}
|
| 3258 |
+
}
|
| 3259 |
+
|
| 3260 |
+
const rawText = await response.text();
|
| 3261 |
+
if (!rawText || rawText.trim() === "") continue;
|
| 3262 |
+
|
| 3263 |
+
let result;
|
| 3264 |
+
try { result = JSON.parse(rawText); } catch(e) { continue; }
|
| 3265 |
+
if (result.curl_error) continue;
|
| 3266 |
+
|
| 3267 |
+
job.status = result.status;
|
| 3268 |
+
const backendProgress = result.progress || 0;
|
| 3269 |
+
job.progress = 20 + Math.floor(backendProgress * 0.8);
|
| 3270 |
+
|
| 3271 |
+
if (result.filename) job.filename = result.filename;
|
| 3272 |
+
|
| 3273 |
+
if (job.status === 'completed') {
|
| 3274 |
+
job.progress = 100;
|
| 3275 |
+
job.step_desc = 'تکمیل شد';
|
| 3276 |
+
} else if (job.status === 'failed') {
|
| 3277 |
+
job.step_desc = 'خطا در سرور: ' + (result.detail || 'نامشخص');
|
| 3278 |
+
} else {
|
| 3279 |
+
job.step_desc = `در حال پردازش قطعات (${backendProgress}%)`;
|
| 3280 |
+
}
|
| 3281 |
+
|
| 3282 |
+
window.saveJob(job);
|
| 3283 |
+
|
| 3284 |
+
} catch (e) {
|
| 3285 |
+
console.error("Polling error for job " + job.job_id, e);
|
| 3286 |
+
}
|
| 3287 |
+
} else {
|
| 3288 |
+
try {
|
| 3289 |
+
const response = await fetch(`${PROXY_URL_BASE}check-action-status&run_id=${job.job_id}`, {
|
| 3290 |
+
method: 'POST',
|
| 3291 |
+
headers: {
|
| 3292 |
+
'Content-Type': 'application/json',
|
| 3293 |
+
'X-App-Auth': secureToken,
|
| 3294 |
+
'X-CSRF-Token': globalCsrfToken
|
| 3295 |
+
},
|
| 3296 |
+
body: JSON.stringify({ email: currentUser.email, fingerprint: currentUser.fingerprint })
|
| 3297 |
+
});
|
| 3298 |
+
|
| 3299 |
+
if (!response.ok) {
|
| 3300 |
+
if (response.status === 401) {
|
| 3301 |
const modal = document.getElementById('session-conflict-modal');
|
| 3302 |
if(modal) modal.classList.add('visible');
|
| 3303 |
+
return;
|
| 3304 |
}
|
| 3305 |
+
continue;
|
| 3306 |
+
}
|
|
|
|
|
|
|
|
|
|
| 3307 |
|
| 3308 |
+
const statusData = await response.json();
|
| 3309 |
+
|
| 3310 |
+
if (statusData.status === 'ready') {
|
| 3311 |
+
const fileUrlLower = statusData.url.toLowerCase();
|
| 3312 |
+
|
| 3313 |
+
// جلوگیری از پذیرش عکس خطا به عنوان خروجی صوتی موفقیت آمیز
|
| 3314 |
+
if (fileUrlLower.endsWith('.png') || fileUrlLower.endsWith('.jpg') || fileUrlLower.endsWith('.jpeg') || fileUrlLower.endsWith('.txt')) {
|
| 3315 |
+
job.status = 'failed';
|
| 3316 |
+
job.error = 'پردازش ابری متوقف شد (احتمالاً سهمیه سرور پردازشگر موقتاً پر شده است).';
|
| 3317 |
+
window.saveJob(job);
|
| 3318 |
+
continue;
|
| 3319 |
+
}
|
| 3320 |
|
| 3321 |
+
job.status = 'completed';
|
| 3322 |
+
job.progress = 100;
|
| 3323 |
+
job.step_desc = 'تکمیل شد';
|
| 3324 |
+
job.filename = statusData.url;
|
| 3325 |
+
window.saveJob(job);
|
| 3326 |
+
} else if (statusData.status === 'failed') {
|
| 3327 |
+
job.status = 'failed';
|
| 3328 |
+
job.error = statusData.message || 'خطا در عملیات سیستمی';
|
| 3329 |
+
window.saveJob(job);
|
| 3330 |
+
} else {
|
| 3331 |
+
job.progress = Math.min(95, (job.progress || 20) + 5);
|
| 3332 |
+
job.step_desc = 'در حال انجام عملیات ابری...';
|
| 3333 |
+
window.saveJob(job);
|
| 3334 |
+
}
|
| 3335 |
|
| 3336 |
+
} catch (e) {
|
| 3337 |
+
console.error("Polling error for github action job " + job.job_id, e);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3338 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3339 |
}
|
| 3340 |
}
|
| 3341 |
}
|
| 3342 |
|
| 3343 |
setInterval(checkPendingJobs, 5000);
|
| 3344 |
|
| 3345 |
+
// بررسی دورهای اعتبار نشست در پسزمینه — تا اگه از دستگاه دیگری با همین
|
| 3346 |
+
// شماره/ایمیل وارد شدن، همین دستگاه هم زودتر (بدون نیاز به کلیک روی تولید صدا) متوجه بشه
|
| 3347 |
+
async function checkSessionValidity() {
|
| 3348 |
+
if (!currentUser.email) return;
|
| 3349 |
+
try {
|
| 3350 |
+
const secureToken = generateSecureToken();
|
| 3351 |
+
const response = await fetch(`${PROXY_URL_BASE}check-session`, {
|
| 3352 |
+
method: 'POST',
|
| 3353 |
+
headers: {
|
| 3354 |
+
'Content-Type': 'application/json',
|
| 3355 |
+
'X-App-Auth': secureToken,
|
| 3356 |
+
'X-CSRF-Token': globalCsrfToken
|
| 3357 |
+
},
|
| 3358 |
+
body: JSON.stringify({ email: currentUser.email, fingerprint: currentUser.fingerprint })
|
| 3359 |
+
});
|
| 3360 |
+
if (response.status === 401) {
|
| 3361 |
+
const result = await response.json().catch(() => ({}));
|
| 3362 |
+
if (result.force_logout) {
|
| 3363 |
+
const modal = document.getElementById('session-conflict-modal');
|
| 3364 |
+
if (modal) modal.classList.add('visible');
|
| 3365 |
+
}
|
| 3366 |
+
}
|
| 3367 |
+
} catch (e) {
|
| 3368 |
+
// خطای شبکه موقت را نادیده بگیر؛ چک بعدی خودش دوباره تلاش میکند
|
| 3369 |
+
}
|
| 3370 |
+
}
|
| 3371 |
+
setInterval(checkSessionValidity, 20000);
|
| 3372 |
+
document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible') checkSessionValidity(); });
|
| 3373 |
+
window.addEventListener('focus', checkSessionValidity);
|
| 3374 |
+
|
| 3375 |
function setupEventListeners() {
|
| 3376 |
+
if(loginCheckBtn) loginCheckBtn.addEventListener('click', () => { showModal(emailModal); hideLoginLockCountdown(); });
|
| 3377 |
|
| 3378 |
if(logoutBtn) logoutBtn.addEventListener('click', async () => {
|
| 3379 |
if(currentUser.email) {
|
|
|
|
| 3458 |
document.getElementById('phone-display-box').textContent = phone;
|
| 3459 |
emailForm.style.display = 'none';
|
| 3460 |
codeForm.style.display = 'block';
|
| 3461 |
+
const googleBlock = document.getElementById('google-signin-block');
|
| 3462 |
+
if (googleBlock) googleBlock.style.display = 'none';
|
| 3463 |
});
|
| 3464 |
|
| 3465 |
if(codeForm) codeForm.addEventListener('submit', async (e) => {
|
|
|
|
| 3479 |
body: JSON.stringify({ email: phone, fingerprint: stableFingerprint })
|
| 3480 |
});
|
| 3481 |
const result = await response.json();
|
| 3482 |
+
if (response.status === 429 && result.locked) {
|
| 3483 |
+
showLoginLockCountdown(result.locked_until);
|
| 3484 |
+
return;
|
| 3485 |
+
}
|
| 3486 |
if (!response.ok) throw new Error(result.message || 'خطا در تایید شماره.');
|
| 3487 |
localStorage.setItem('userEmail', phone);
|
| 3488 |
localStorage.setItem('sada_device_fp', stableFingerprint);
|
|
|
|
| 3490 |
currentUser.fingerprint = stableFingerprint;
|
| 3491 |
hideModal(emailModal);
|
| 3492 |
await checkUserStatus(phone);
|
| 3493 |
+
if (result.previous_session_ended) {
|
| 3494 |
+
setTimeout(() => alert('توجه: این حساب روی دستگاه دیگری هم فعال بود؛ نشست قبلی بسته شد و از این پس همین دستگاه فعاله.'), 400);
|
| 3495 |
+
}
|
| 3496 |
} catch (error) {
|
| 3497 |
alert(error.message);
|
| 3498 |
} finally {
|
|
|
|
| 3501 |
}
|
| 3502 |
});
|
| 3503 |
|
| 3504 |
+
if(backToEmailBtn) backToEmailBtn.addEventListener('click', () => { hideLoginLockCountdown(); });
|
| 3505 |
[changeSpeakerBtn, selectedSpeakerCard].forEach(el => el && el.addEventListener('click', () => { isMainSelectorAction = true; createSpeakerCardsInModal(); showModal(speakerModal); }));
|
| 3506 |
if(backToStandardBtn) backToStandardBtn.addEventListener('click', () => switchView('standard', true));
|
| 3507 |
document.querySelectorAll('.modal-overlay').forEach(o => o.addEventListener('click', (e) => (e.target === o) && hideModal(o)));
|
|
|
|
| 3566 |
const userStatusPromise = checkUserStatus(currentUser.email);
|
| 3567 |
|
| 3568 |
setupEventListeners();
|
| 3569 |
+
initGoogleSignIn();
|
| 3570 |
|
| 3571 |
await podcastDBPromise;
|
| 3572 |
await mainDBPromise;
|