diff --git a/.gitignore b/.gitignore index 06c8f11c5..26240bd12 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ venv /*.bat /*.sh /*.txt +/notification.mp3 !webui.bat !webui.sh diff --git a/html/notification_default.mp3 b/html/notification_default.mp3 new file mode 100644 index 000000000..dba530bf7 Binary files /dev/null and b/html/notification_default.mp3 differ diff --git a/modules/shared.py b/modules/shared.py index 32e8b0ab7..5bf2d14d7 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -412,6 +412,8 @@ options_templates.update(options_section(('ui', "Live previews"), { "show_progressbar": OptionInfo(True, "Show progressbar"), "live_previews_enable": OptionInfo(True, "Show live previews of the created image"), "show_progress_grid": OptionInfo(True, "Show previews of all images generated in a batch as a grid"), + "notification_audio_enable": OptionInfo(False, "Play a sound when images are finished generating."), + "notification_audio_path": OptionInfo("html/notification_default.mp3","Path to notification sound",component_args=hide_dirs), "show_progress_every_n_steps": OptionInfo(1, "Show new live preview image every N sampling steps. Set to -1 to show after completion of batch.", gr.Slider, {"minimum": -1, "maximum": 32, "step": 1}), "show_progress_type": OptionInfo("Approx NN", "Image creation progress preview mode", gr.Radio, {"choices": ["Full", "Approx NN", "Approx cheap"]}), "live_preview_content": OptionInfo("Combined", "Live preview subject", gr.Radio, {"choices": ["Combined", "Prompt", "Negative prompt"]}), diff --git a/modules/ui.py b/modules/ui.py index 475d6c889..1edb4111c 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -1384,6 +1384,9 @@ def create_ui(): with gr.TabItem(label, id=ifid, elem_id='tab_' + ifid): interface.render() + if opts.notification_audio_enable and os.path.exists(os.path.join(script_path, opts.notification_audio_path)): + audio_notification = gr.Audio(interactive=False, value=os.path.join(script_path, opts.notification_audio_path), elem_id="audio_notification", visible=False) + text_settings = gr.Textbox(elem_id="settings_json", value=lambda: opts.dumpjson(), visible=False) settings_submit.click( fn=wrap_gradio_call(run_settings, extra_outputs=[gr.update()]),