mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
Added better feedback for downloading audio file since it can take some time to combine the chunks.
This commit is contained in:
31
aiserver.py
31
aiserver.py
@@ -7932,20 +7932,19 @@ def UI_2_audio():
|
||||
#==================================================================#
|
||||
# Download complete audio file
|
||||
#==================================================================#
|
||||
@app.route("/audio_full")
|
||||
@require_allowed_ip
|
||||
@logger.catch
|
||||
def UI_2_audio_full():
|
||||
@socketio.on("gen_full_audio")
|
||||
def UI_2_gen_full_audio(data):
|
||||
from pydub import AudioSegment
|
||||
if args.no_ui:
|
||||
return redirect('/api/latest')
|
||||
|
||||
logger.info("Downloading complete audio file")
|
||||
logger.info("Generating complete audio file")
|
||||
combined_audio = None
|
||||
complete_filename = os.path.join(koboldai_vars.save_paths.generated_audio, "complete.ogg")
|
||||
for action_id in range(-1, koboldai_vars.actions.action_count+1):
|
||||
filename = os.path.join(koboldai_vars.save_paths.generated_audio, f"{action_id}.ogg")
|
||||
filename_slow = os.path.join(koboldai_vars.save_paths.generated_audio, f"{action_id}_slow.ogg")
|
||||
complete_filename = os.path.join(koboldai_vars.save_paths.generated_audio, "complete.ogg")
|
||||
|
||||
|
||||
if os.path.exists(filename_slow):
|
||||
if combined_audio is None:
|
||||
@@ -7972,12 +7971,22 @@ def UI_2_audio_full():
|
||||
|
||||
logger.info("Sending audio file")
|
||||
file_handle = combined_audio.export(complete_filename, format="ogg")
|
||||
return True
|
||||
|
||||
return send_file(
|
||||
complete_filename,
|
||||
as_attachment=True,
|
||||
download_name = koboldai_vars.story_name,
|
||||
mimetype="audio/ogg")
|
||||
|
||||
@app.route("/audio_full")
|
||||
@require_allowed_ip
|
||||
@logger.catch
|
||||
def UI_2_audio_full():
|
||||
logger.info("Downloading complete audio file")
|
||||
complete_filename = os.path.join(koboldai_vars.save_paths.generated_audio, "complete.ogg")
|
||||
if os.path.exists(complete_filename):
|
||||
return send_file(
|
||||
complete_filename,
|
||||
as_attachment=True,
|
||||
download_name = koboldai_vars.story_name,
|
||||
mimetype="audio/ogg")
|
||||
|
||||
|
||||
#==================================================================#
|
||||
# Download of the image for an action
|
||||
|
@@ -3791,10 +3791,18 @@ function stop_tts() {
|
||||
}
|
||||
|
||||
function download_tts() {
|
||||
var link = document.createElement("a");
|
||||
link.download = document.getElementsByClassName("var_sync_story_story_name ")[0].text+".ogg";
|
||||
link.href = "/audio_full";
|
||||
link.click();
|
||||
document.getElementById("download_tts").innerText = "hourglass_empty";
|
||||
socket.emit("gen_full_audio", {}, download_actual_file_tts);
|
||||
}
|
||||
|
||||
function download_actual_file_tts(data) {
|
||||
if (data) {
|
||||
var link = document.createElement("a");
|
||||
link.download = document.getElementsByClassName("var_sync_story_story_name ")[0].text+".ogg";
|
||||
link.href = "/audio_full";
|
||||
link.click();
|
||||
document.getElementById("download_tts").innerText = "download";
|
||||
}
|
||||
}
|
||||
|
||||
function finished_tts() {
|
||||
|
@@ -109,7 +109,7 @@
|
||||
<span class="tts_controls hidden var_sync_alt_story_gen_audio">
|
||||
<button type="button" class="btn action_button" style="width: 30px; padding: 0px;" onclick='play_pause_tts()' aria-label="play"><span id="play_tts" class="material-icons-outlined" style="font-size: 1.4em;">play_arrow</span></button>
|
||||
<button type="button" class="btn action_button" style="width: 30px; padding: 0px;" onclick='stop_tts()' aria-label="play"><span id="stop_tts" class="material-icons-outlined" style="font-size: 1.4em;">stop</span></button>
|
||||
<button type="button" class="btn action_button" style="width: 30px; padding: 0px;" onclick='download_tts()' aria-label="play"><span id="stop_tts" class="material-icons-outlined" style="font-size: 1.4em;">download</span></button>
|
||||
<button type="button" class="btn action_button" style="width: 30px; padding: 0px;" onclick='download_tts()' aria-label="play"><span id="download_tts" class="material-icons-outlined" style="font-size: 1.4em;">download</span></button>
|
||||
</span>
|
||||
<button type="button" class="btn action_button submit var_sync_alt_system_aibusy" system_aibusy=False id="btnsubmit" onclick="storySubmit();" context-menu="submit-button">Submit</button>
|
||||
<button type="button" class="btn action_button submited var_sync_alt_system_aibusy" system_aibusy=False id="btnsent"><img id="thinking" src="static/thinking.gif" class="force_center" onclick="socket.emit('abort','');"></button>
|
||||
|
Reference in New Issue
Block a user