From d674c4d460ae315a76e3fe8cab23d18713b41d5e Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Wed, 22 Apr 2026 22:03:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=81=A2=E5=A4=8D=E7=AE=80=E5=8D=95?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E9=80=BB=E8=BE=91=EF=BC=8C=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=A4=8D=E6=9D=82=E7=9A=84=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logs/server.log | Bin 211236 -> 11657 bytes static/tts.html | 38 +------------------------------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/logs/server.log b/logs/server.log index df137f3c91d00b228f7c69c443abe4076a5c4be5..1dc406c63a6f0a7e71828ee04caf3bc80289f8ac 100644 GIT binary patch delta 157 zcmZ4TiKjDqf(omtiJ?L4^aKlL@re%eSj|i<%uFX2GMjQ38d#xoER29M<}5%BmXjM< zEJ2Db%#akLa4Zc$idjvJjg3u^)L0^$4(2FswqbAAobGACe3`@C(8$!nGL{PfW3?vb delta 616 zcmcJM!Aiq09L8DKfrxkUFcycf4eZ*aNt=kEf>jUV2KFW*U7NaITCv$gUqHM$@(P~4 z415T$K8Zeo$#5`Kym<*f!k7HN@B2TTJ$`AI6BArv{k+DOn0mKza6i2`MmkI;b0Q diff --git a/static/tts.html b/static/tts.html index f79d6d0..fdf2012 100644 --- a/static/tts.html +++ b/static/tts.html @@ -545,25 +545,6 @@ let currentVoice = 'zh-CN-XiaoxiaoNeural'; let autoPlay = true; // 自动播放开关 let volumeLevel = 1.5; // 音量倍率 - let audioUnlocked = false; // 音频播放是否解锁 - - // 解锁音频播放(浏览器需要用户交互后才能自动播放) - function unlockAudio() { - if (!audioUnlocked) { - // 创建一个静音音频来解锁 - const silentAudio = new Audio(); - silentAudio.play().then(() => { - audioUnlocked = true; - console.log('音频播放已解锁'); - }).catch(e => { - console.log('音频解锁失败:', e); - }); - } - } - - // 页面点击解锁音频 - document.addEventListener('click', unlockAudio, { once: true }); - document.addEventListener('touchstart', unlockAudio, { once: true }); // 元素 const statusDot = document.getElementById('statusDot'); @@ -947,9 +928,6 @@ const audio = new Audio(url); const icon = btn.querySelector('.play-icon'); - // 应用音量倍率 - audio.volume = Math.min(volumeLevel, 2); // 最大不超过2 - audio.onplay = () => { icon.textContent = '🔊'; btn.classList.add('playing'); @@ -960,21 +938,7 @@ btn.classList.remove('playing'); }; - audio.onerror = (e) => { - console.error('音频播放失败:', url, e); - icon.textContent = '❌'; - btn.classList.remove('playing'); - }; - - // 添加播放失败的catch - audio.play().catch(e => { - console.error('播放被阻止:', e); - icon.textContent = '🔇'; - // 提示用户点击播放 - if (e.name === 'NotAllowedError') { - showError('请先点击页面解锁音频播放'); - } - }); + audio.play(); } // 显示加载