From 414aa72a742c0965e34811748a8182ec494b6720 Mon Sep 17 00:00:00 2001 From: Cassianvale <1544257291@qq.com> Date: Sat, 1 Jun 2024 21:54:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=A4=9A=E9=9F=B3?= =?UTF-8?q?=E9=A2=91=E6=96=87=E4=BB=B6API=E5=B1=95=E7=A4=BA=E6=97=A0?= =?UTF-8?q?=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 1 - templates/index.html | 123 +++++++++++++++++++------------------------ 2 files changed, 53 insertions(+), 71 deletions(-) diff --git a/app.py b/app.py index 87485db..5b65909 100644 --- a/app.py +++ b/app.py @@ -168,7 +168,6 @@ def tts(): sample_rate = 24000 # Assuming 24kHz sample rate audio_duration = len(combined_wavdata) / sample_rate audio_duration_rounded = round(audio_duration, 2) - app.logger.info(f"音频时长: {audio_duration_rounded} 秒") print(f"音频时长: {audio_duration_rounded} 秒") sf.write(WAVS_DIR+'/'+filename, combined_wavdata, 24000) diff --git a/templates/index.html b/templates/index.html index 81939de..0fb53ed 100644 --- a/templates/index.html +++ b/templates/index.html @@ -123,8 +123,7 @@

ChatTTS WebUI & API(v{{version}})ChatTTS WebUI & API(v{{version}}) -
${filename}
- -
推理时间: ${audio.inference_time} 秒
-
生成时间: ${audio.audio_duration} 秒
- - -
- - - `); - - $(`#${buttonId}`).click(function() { - let codeId = `#code-${index}`; - $(codeId).toggleClass('d-none'); - if (!$(codeId).hasClass('d-none')) { - $(codeId).html(`
${jsCode}
`); - } - }); - }); - - audioGenerated = true; - } else { - layer.alert('音频文件生成失败', {title: false}); - } - } else { - layer.alert(response.msg,{title:false}); - } - }, - error: function(xhr, status, error) { - layer.alert('发生错误: ' + error,{title:false}); - }, - complete:function(){ - layer.close(index) - } - }); - } - }); - - // Show API call example button - $('#show-js-btn').click(function() { - if (audioGenerated) { - $('#code').toggleClass('d-none'); - $('#show-js-btn').toggleClass('btn-warning'); - if (!$('#code').hasClass('d-none')) { - $('#code').html(`
${jsCode}
`); + $('#audio-container').append(` +
+
${filename}
+ +
推理时长: ${audio.inference_time} 秒
+
音频时长: ${audio.audio_duration} 秒
+ +
+
+ `); + }); + + audioGenerated = true; + } else { + layer.alert('音频文件生成失败', {title: false}); } - } else { - layer.alert('请先生成音频文件', {title: false}); + } else { + layer.alert(response.msg, {title: false}); + } + }, + error: function(xhr, status, error) { + layer.alert('发生错误: ' + error, {title: false}); + }, + complete: function() { + layer.close(index); } - }); + }); + } + }); + + $(document).on('click', '.show-js-btn', function() { + let codeContainer = $(this).next('.code-container'); + codeContainer.toggleClass('d-none'); + if (!codeContainer.hasClass('d-none')) { + codeContainer.html(`
${decodeURIComponent($(this).data('js-code'))}
`); + } + }); + $('#upload-btn').click(function() { $('#file-input').click(); // Trigger file input when upload button is clicked