diff --git a/audio_cache/8bc65e9ebfc94095a698d1fc1b742428.mp3 b/audio_cache/8bc65e9ebfc94095a698d1fc1b742428.mp3 new file mode 100644 index 0000000..23f4aca Binary files /dev/null and b/audio_cache/8bc65e9ebfc94095a698d1fc1b742428.mp3 differ diff --git a/logs/server.log b/logs/server.log index 7c96574..25c8fcb 100644 Binary files a/logs/server.log and b/logs/server.log differ diff --git a/static/tts.html b/static/tts.html index e50a0b7..6eeb6ca 100644 --- a/static/tts.html +++ b/static/tts.html @@ -124,6 +124,96 @@ color: #999; } + /* TTS 控制选项 */ + .tts-controls { + display: flex; + gap: 15px; + margin-top: 12px; + padding-top: 12px; + border-top: 1px solid #eee; + align-items: center; + } + + .auto-play-switch { + display: flex; + align-items: center; + gap: 8px; + } + + .switch { + position: relative; + width: 44px; + height: 22px; + } + + .switch input { + opacity: 0; + width: 0; + height: 0; + } + + .slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #ccc; + transition: .3s; + border-radius: 22px; + } + + .slider:before { + position: absolute; + content: ""; + height: 18px; + width: 18px; + left: 2px; + bottom: 2px; + background-color: white; + transition: .3s; + border-radius: 50%; + } + + input:checked + .slider { + background-color: #667eea; + } + + input:checked + .slider:before { + transform: translateX(22px); + } + + .volume-control { + display: flex; + align-items: center; + gap: 8px; + } + + .volume-control input[type="range"] { + width: 80px; + height: 6px; + border-radius: 3px; + background: #ddd; + outline: none; + -webkit-appearance: none; + } + + .volume-control input[type="range"]::-webkit-slider-thumb { + -webkit-appearance: none; + width: 14px; + height: 14px; + border-radius: 50%; + background: #667eea; + cursor: pointer; + } + + .volume-value { + font-size: 12px; + color: #666; + min-width: 35px; + } + .voice-select { margin-top: 10px; } @@ -388,6 +478,20 @@ +
@@ -439,6 +543,8 @@ let conversationId = null; let currentTTSProvider = 'none'; let currentVoice = 'zh-CN-XiaoxiaoNeural'; + let autoPlay = true; // 自动播放开关 + let volumeLevel = 1.5; // 音量倍率 // 元素 const statusDot = document.getElementById('statusDot'); @@ -453,6 +559,10 @@ const ttsOptions = document.getElementById('ttsOptions'); const voiceSelect = document.getElementById('voiceSelect'); const voiceDropdown = document.getElementById('voiceDropdown'); + const ttsControls = document.getElementById('ttsControls'); + const autoPlaySwitch = document.getElementById('autoPlaySwitch'); + const volumeSlider = document.getElementById('volumeSlider'); + const volumeValue = document.getElementById('volumeValue'); // 初始化 async function init() { @@ -531,6 +641,9 @@ // 显示/隐藏音色选择 voiceSelect.style.display = provider === 'edge' ? 'block' : 'none'; + // 显示/隐藏控制选项(有TTS才显示) + ttsControls.style.display = provider !== 'none' ? 'flex' : 'none'; + // 保存设置 saveTTSSettings(); } @@ -779,8 +892,10 @@ `; } else if (role === 'assistant') { let audioHtml = ''; + let audioBtnId = ''; if (audioData) { - audioHtml = `