Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding notification.mp3 support #606

Merged
merged 4 commits into from
May 2, 2023

Conversation

DrakeRichards
Copy link
Contributor

Description

Automatic1111 had a feature that would play a sound if "notification.mp3" was present in the root folder (added in AUTOMATIC1111/stable-diffusion-webui#1126). This feature is not present in the vladmandic fork, so this PR re-adds it.

Notes

I don't know if this feature was intentionally removed or if it just got left out somehow. Please let me know if its removal was intentional.

Environment and Testing

Release: 3b6effe
OS: Windows 11
Browser: Firefox 112.0.1 (64-bit)

@vladmandic
Copy link
Owner

this relies on user to know to upload notification.mp3 and there is no way to control it.
i removed it because it didn't have any of those done and i hate hard-coded stuff that nobody knows about.if you want to re-add this feature, it needs to be a) configurable, b) disabled by default, c) provide some default sound

@DrakeRichards
Copy link
Contributor Author

That makes sense. It will take some more work to implement that, so I’ll close the PR and resubmit later.

@joe85
Copy link

joe85 commented Apr 29, 2023

@DrakeRichards

You can add a setting to shared.py, I am not sure where is best but Live Previews seems okay to me.

options_templates.update(options_section(('ui', "Live previews"), {
    "play_sound_on_complete": OptionInfo(False, "Play sound on completion"),

Then in ui.py reference your setting:

if opts.play_sound_on_complete and os.path.exists(os.path.join(script_path, "notification.mp3")):
            audio_notification = gr.Audio(interactive=False, value=os.path.join(script_path, "notification.mp3"), elem_id="audio_notification", visible=False)

Here's a royalty free notification sound:
https://pixabay.com/sound-effects/the-notification-email-143029/

@vladmandic
Copy link
Owner

yup. except then there is no need for os.path.exists and it should probably go to /html, not stay in root.

@GammelSami
Copy link

Looking forward to this! I already know what sound effect I'll use. 👀 https://youtu.be/Vl3cmacvVm4

@vladmandic
Copy link
Owner

btw, why not keep pr as draft while working on it? when you mark it as ready for review, i'll take a look at it.

@DrakeRichards
Copy link
Contributor Author

btw, why not keep pr as draft while working on it? when you mark it as ready for review, i'll take a look at it.

I wasn't aware I could do that; thank you! Still learning GitHub.

@DrakeRichards DrakeRichards reopened this May 1, 2023
@DrakeRichards DrakeRichards marked this pull request as draft May 1, 2023 23:11
@DrakeRichards
Copy link
Contributor Author

I've added two settings to the "Live Previews" tab:

  • Toggle to enable the notification sound.
  • Text box with a path to the sound.

I've also added html/notification_default.mp3 and the relevant .gitignore entries for other .mp3 files.

image

@DrakeRichards DrakeRichards marked this pull request as ready for review May 2, 2023 00:57
@vladmandic vladmandic merged commit 568e700 into vladmandic:master May 2, 2023
@brknsoul
Copy link
Contributor

brknsoul commented May 2, 2023

Thank you, you awesome dudes!

@TKS4
Copy link

TKS4 commented May 3, 2023

Does this work? Enabled or disabled makes no difference for me. I'm on latest FF, I recall in the OG repo, you'd have to enable notifications (like the kind that gets pushed to you by the browser to your OS), and then I supposed the sound would work. But this, doesn't work. Maybe the default audio device isn't being pinged?

@GammelSami
Copy link

GammelSami commented May 3, 2023

Does this work? Enabled or disabled makes no difference for me.

Yes it works. You have to reload UI (or even better restart the server) after saving the changed setting.

It is not a real browser Notification. It's just playing a sound using html <audio>. Maybe your browser blocks playing audio from this tab, but usually browsers auto enable sound playback after you interact with the website once.

@TKS4
Copy link

TKS4 commented May 4, 2023

Yes it works. You have to reload UI (or even better restart the server) after saving the changed setting.

Seems there was a commit that 'fixes notification'. And now functions properly 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants