در زیر کد کامل شما با اضافه کردن دکمههای دانلود، توضیحات و قابلیت شناسایی فایلهای MP3 آمده است. تمام تغییرات اضافی به جز موارد خواسته شده حفظ شده است.
<!DOCTYPE html>
<html lang="fa">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>صفحه تبدیل متن به صدا</title>
<style>
/* عمومی استایلها */
html, body {
margin: 0;
padding: 0;
background-color: #f0f0f0;
font-family: Arial, sans-serif;
height: 100vh;
overflow: hidden;
scroll-behavior: smooth; /* اضافه کردن اسکرول نرم */
}
/* کانتینر iframe */
.iframe-container {
position: relative;
width: 100%;
height: 100vh;
overflow: hidden;
}
iframe {
width: 100%;
height: calc(100% + 113.4px); /* تغییر ارتفاع برای مخفی کردن 3 سانتیمتر */
border: none;
display: none; /* مخفی کردن iframe تا بارگذاری شود */
position: relative;
top: -113.4px; /* مخفی کردن 3 سانتیمتر از بالای صفحه */
}
/* لودینگ و پروگرس بار */
.loading {
position: fixed; /* قرارگیری روی کل صفحه */
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
align-items: center;
z-index: 10000;
}
.loading-message {
margin-bottom: 20px;
font-size: 18px;
text-align: center;
}
.progress {
width: 80%;
max-width: 400px;
height: 20px;
background-color: #ddd;
border-radius: 5px;
overflow: hidden;
}
.progress-bar {
height: 100%;
width: 0;
background-color: #4caf50;
transition: width 1s;
}
.error-message {
display: none;
color: red;
margin-top: 20px;
font-size: 16px;
text-align: center;
}
#retryButton {
display: none;
margin-top: 10px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
background-color: #4caf50;
color: white;
border: none;
border-radius: 5px;
}
/* دکمههای دانلود و توضیحات */
.download-button, .description-button {
display: block;
width: 100px; /* کاهش عرض دکمه */
color: white;
text-align: center;
padding: 8px; /* کاهش پدینگ */
border-radius: 5px;
cursor: pointer;
font-size: 12px; /* کاهش اندازه فونت */
transition: background-color 0.3s;
position: fixed;
top: 10px;
z-index: 10001;
text-decoration: none;
}
.download-button {
background-color: #4CAF50;
right: 10px; /* موقعیت fixed در سمت راست */
}
.description-button {
background-color: rgb(84, 110, 122);
left: 10px; /* موقعیت fixed در سمت چپ */
}
.download-button:hover, .description-button:hover {
background-color: #45a049;
}
/* دکمه دانلود در پایین صفحه */
.download-button-bottom {
position: fixed;
bottom: 10px;
left: 50%;
transform: translateX(-50%);
background-color: #4CAF50;
padding: 14px 24px; /* افزایش پدینگ عمودی و افقی برای اندازه بیشتر */
border-radius: 5px;
color: white;
text-align: center;
font-size: 16px;
text-decoration: none;
z-index: 10001;
cursor: pointer;
box-sizing: border-box; /* شامل شدن پدینگ در محاسبه عرض */
display: none; /* مخفی کردن دکمه در ابتدا */
width: 250px; /* افزایش عرض دکمه از 200px به 250px */
}
.download-button-bottom:hover {
background-color: #45a049;
}
/* پنجرههای مودال */
.modal {
display: none;
position: fixed;
z-index: 10002;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}
.modal-content, .confirm-modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
max-width: 500px;
text-align: center;
border-radius: 5px;
}
.confirm-modal-content {
max-width: 400px;
}
.modal-button {
margin-top: 20px;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
}
.cancel-btn {
background-color: #f44336;
color: white;
}
.confirm-btn {
background-color: #4CAF50;
color: white;
}
.confirm-btn:hover {
background-color: #45a049;
}
/* پیام ساخت لینک دانلود */
.notification {
display: none;
position: fixed;
z-index: 10003;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background-color: #ffffff;
padding: 30px;
border-radius: 10px;
text-align: center;
color: #4CAF50;
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}
.notification p {
margin: 0;
font-size: 18px;
}
</style>
</head>
<body>
<!-- دکمههای دانلود و توضیحات -->
<p style="margin: 10px;">
<a href="#" class="download-button" id="downloadButton">دانلود 📥</a>
<a href="#" class="description-button" id="descriptionButton">توضیحات</a>
</p>
<!-- پنجره سفارشی (modal) برای توضیحات -->
<div id="myDescriptionModal" class="modal">
<div class="modal-content">
<hr />
<p style="text-align: center;">نسخه پیشرفته تبدیل متن به صدا با <span style="color: #008080;">هوش مصنوعی </span></p>
<p style="text-align: center;">برای نمایش زبان فارسی قسمت جستجو در کادر بنویسید pers</p>
<p style="text-align: center;">برای استفاده از صدای های طبیعی </p>
<p style="text-align: center;">بعد از دریافت فایل صوتی میتونید برید قسمت تغییر صدا با استفاده از مدل های تغییر صدا فایل صوتی رو به صدا های طبیعی و صدای مورد نظر (صدای افراد مشهور) تبدیل کنید.</p>
<p style="text-align: center;"> </p>
<button class="modal-button cancel-btn" id="closeDescriptionBtn">بستن</button>
</div>
</div>
<!-- پنجره سفارشی (modal) برای نمایش صداهای دانلود شده -->
<div id="myModal" class="modal">
<div class="modal-content">
<p style="text-align: center;">صداهای شناسایی شده</p>
<div class="audio-container" id="audioContainer">
<!-- پلیرهای صدا در اینجا قرار خواهند گرفت -->
</div>
<button class="modal-button cancel-btn" id="closeBtn">بستن</button>
</div>
</div>
<!-- پنجره تأیید دانلود -->
<div id="confirmModal" class="modal">
<div class="confirm-modal-content">
<p>برای دانلود فایل صوتی روی تایید کلیک کنید</p>
<button class="modal-button confirm-btn" id="confirmDownloadBtn">تایید</button>
<button class="modal-button canceled-btn" id="cancelDownloadBtn">لغو</button>
</div>
</div>
<!-- پیام ساخت لینک دانلود -->
<div class="notification" id="buildingLinkNotification">
<p>در حال ساخت لینک دانلود، لطفاً صبر کنید...</p>
</div>
<!-- لودینگ و iframe -->
<div class="iframe-container">
<div class="loading" id="loadingContainer">
<div class="loading-message">لطفاً صبر کنید...</div>
<div class="progress">
<div class="progress-bar" id="progressBar"></div>
</div>
<div class="error-message" id="errorMessage">بارگیری زیاد طول کشید.<br />در صورت عدم بارگذاری، فیلترشکن خود را روشن کنید.</div>
<button id="retryButton">بارگذاری مجدد</button>
</div>
<iframe id="myIframe" sandbox="allow-scripts allow-same-origin allow-forms allow-modals" allow="clipboard-read; clipboard-write"></iframe>
</div>
<!-- دکمه دانلود صدا در پایین صفحه -->
<p><a href="#" class="download-button-bottom" id="downloadButtonBottom">دانلود صدا 📥</a></p>
<script>
let progress = 0;
const progressBar = document.getElementById('progressBar');
const retryButton = document.getElementById('retryButton');
const errorMessage = document.getElementById('errorMessage');
const loadingContainer = document.getElementById('loadingContainer');
const scrollHandle = document.getElementById('scrollHandle');
let interval;
let iframeLoadedFlag = false;
// متغیر برای ذخیرهی لینک فایل صوتی انتخاب شده
let selectedAudioUrl = '';
function startProgress() {
loadingContainer.style.display = 'flex'; // نمایش لودینگ
progressBar.style.width = '0%'; // ریست شدن نوار پیشرفت
progress = 0; // ریست پیشرفت
interval = setInterval(() => {
if (progress < 100) {
progress += 10;
progressBar.style.width = progress + '%';
}
if (progress === 100) {
clearInterval(interval);
if (!iframeLoadedFlag) {
retryButton.style.display = 'block';
errorMessage.style.display = 'block';
}
}
}, 1000);
}
function iframeLoaded() {
iframeLoadedFlag = true;
clearInterval(interval);
loadingContainer.style.display = 'none'; // مخفی کردن لودینگ
document.getElementById('myIframe').style.display = 'block'; // نمایش iframe
// نمایش دکمه دانلود پایین صفحه پس از بارگذاری موفق
document.getElementById('downloadButtonBottom').style.display = 'block';
// نمایش دکمه اسکرول پس از بارگذاری موفق
scrollHandle.style.display = 'flex';
}
function iframeError() {
clearInterval(interval);
retryButton.style.display = 'block';
errorMessage.style.display = 'block';
}
function loadIframe() {
const iframe = document.getElementById('myIframe');
// آدرس iframe خود را در اینجا تنظیم کنید
iframe.src = 'https://text2video.wingetgui.com';
iframe.onload = iframeLoaded;
iframe.onerror = iframeError;
}
function handleDownload(event) {
event.preventDefault();
const iframe = document.getElementById('myIframe');
let iframeDocument;
try {
iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
} catch (error) {
console.error("دسترسی به محتوای iframe به دلیل محدودیتهای امنیتی امکانپذیر نیست.", error);
alert("دسترسی به محتوای iframe به دلیل محدودیتهای امنیتی امکانپذیر نیست.");
return;
}
try {
const links = iframeDocument.querySelectorAll('a');
if (links.length === 0) {
alert("هیچ لینک صوتی برای دانلود یافت نشد.");
return;
}
let audioFiles = [];
links.forEach((link) => {
const href = link.href;
if (href && (href.toLowerCase().endsWith('.mp3') || href.toLowerCase().endsWith('.wav'))) {
audioFiles.push(href);
}
});
if (audioFiles.length === 0) {
alert("هیچ فایل صوتی ساخته شده یافت نشد.");
return;
}
// محدود به دو فایل
audioFiles = audioFiles.slice(0, 2);
const audioContainer = document.getElementById('audioContainer');
audioContainer.innerHTML = '';
audioFiles.forEach((audioUrl, index) => {
const audioItem = document.createElement('div');
audioItem.classList.add('audio-item');
// تعیین برچسب بر اساس شماره پلیر
let labelText = '';
if (index === 0) {
labelText = 'خروجی صدا';
} else if (index === 1) {
labelText = 'خروجی صدای پیشرفته';
}
audioItem.innerHTML = `
<p class="audio-label">${labelText}</p>
<audio controls class="audio-player">
<source src="${audioUrl}" type="audio/mp3">
مرورگر شما از پخش این فایل صوتی پشتیبانی نمیکند.
</audio>
<button class="download-audio-button" onclick="downloadAudio('${audioUrl}')">دانلود صدا</button>
`;
audioContainer.appendChild(audioItem);
});
document.getElementById('myModal').style.display = 'block';
} catch (error) {
console.error("خطا در شناسایی صداها: ", error);
alert("خطایی در شناسایی صداها رخ داد.");
}
}
function downloadAudio(audioUrl) {
// ذخیره لینک فایل صوتی انتخاب شده
selectedAudioUrl = audioUrl;
// نمایش پنجره تأیید
document.getElementById('confirmModal').style.display = 'block';
}
// Event listener برای دکمه تایید دانلود
document.getElementById('confirmDownloadBtn').addEventListener('click', function() {
if (selectedAudioUrl) {
// نمایش پیام ساخت لینک دانلود
const buildingLinkNotification = document.getElementById('buildingLinkNotification');
buildingLinkNotification.style.display = 'block';
// دریافت فایل صوتی به صورت blob
fetch(selectedAudioUrl)
.then(response => response.blob())
.then(blob => {
// آمادهسازی فرم دیتا
const formData = new FormData();
formData.append('audio', blob, 'downloaded_audio.mp3'); // تغییر نام فایل به mp3
// ارسال فایل به upload.php
return fetch('https://www.aisada.ir/hamed/upload.php', { // آدرس کامل upload.php در سرور خودتان
method: 'POST',
body: formData,
mode: 'cors'
});
})
.then(response => response.json())
.then(data => {
buildingLinkNotification.style.display = 'none';
if (data.success) {
if (confirm("لینک دانلود آماده است. برای دانلود فایل روی تایید کلیک کنید. ")) {
// باز کردن لینک جدید در تب جدید
window.open(data.url, '_blank');
}
} else {
alert('خطا در آپلود فایل صوتی: ' + data.message);
}
})
.catch(error => {
buildingLinkNotification.style.display = 'none';
console.error('خطا:', error);
alert('خطا در آپلود فایل صوتی');
});
// بسته شدن پنجره تأیید
document.getElementById('confirmModal').style.display = 'none';
// پاک کردن متغیر بعد از استفاده
selectedAudioUrl = '';
}
});
// Event listener برای دکمه لغو دانلود
document.getElementById('cancelDownloadBtn').addEventListener('click', function() {
// بسته شدن پنجره تأیید
document.getElementById('confirmModal').style.display = 'none';
// پاک کردن متغیر
selectedAudioUrl = '';
});
// Event listeners برای دکمه دریافت صدا
document.getElementById('downloadButton').addEventListener('click', handleDownload);
document.getElementById('downloadButtonBottom').addEventListener('click', handleDownload);
// بستن پنجره مودالها با کلیک خارج از آنها
window.addEventListener('click', function(event) {
const modals = ['myModal', 'myDescriptionModal', 'confirmModal', 'buildingLinkNotification'];
modals.forEach(modalId => {
const modal = document.getElementById(modalId);
if (event.target == modal) {
modal.style.display = 'none';
}
});
});
// مدیریت پنجره توضیحات
const descriptionModal = document.getElementById('myDescriptionModal');
const descriptionButton = document.getElementById('descriptionButton');
const closeDescriptionBtn = document.getElementById('closeDescriptionBtn');
descriptionButton.addEventListener('click', function(event) {
event.preventDefault();
descriptionModal.style.display = 'block';
});
closeDescriptionBtn.addEventListener('click', function() {
descriptionModal.style.display = 'none';
});
// مدیریت پنجره بستن مودال صدا
const myModal = document.getElementById('myModal');
const closeBtn = document.getElementById('closeBtn');
closeBtn.addEventListener('click', function() {
myModal.style.display = 'none';
});
// اجرای بارگذاری iframe و آغاز لودینگ
loadIframe();
startProgress();
</script>
</body>
</html>
این کد شامل تمام ویژگیهایی است که شما درخواست کردهاید، از جمله عملکرد دکمههای دانلود و توضیحات، و همچنین قابلیت شناسایی فایلهای به فرمت MP3 به همراه WAV. لطفاً توجه داشته باشید که URL مربوط به iframe و endpoint آپلود باید به درستی تنظیم شود تا به درستی کار کند.