Python package to play a sound when a task completes.
Project description
Python package for playing a sound when a task is complete. The callbacks additionally works also within jupyter notebook, so that if you are working on a notebook on a remote machine it plays the audio within your browser and not in the server.
How do I install this package?
You will need a couple packages that you might not already have installed:
sudo apt install python3-dev
sudo apt install libasound2-dev
Finally as usual, just download it using pip:
pip install ringbell
Support my work ❤️
If you have enjoyed my work, and possibly it has saved you some precious minutes, please do support me on GitHub ❤️
Integration with exceptions and Jupyter Notebooks
In Jupyter Notebooks it is now possible to integrate Ringbell with a one liner, that will play a positive sound when the execution completes successfully and a negative sound when the execution crashes and burns.
Analogous support is added for normal scripts, but only for exceptions since I am not aware of an hook event for the end of a script.
Notification after at least one minute of execution
Since in most Jupyter Notebooks, expecially for experiments, there will be a few very quick cells and then some very long ones, we do not want to spam the user with sounds. The only case where we’d like to advise the user is when enought time has passed since the start of either the script execution or, in case of Jupyter Notebooks, the start of the cell execution.
To do this, simply import the ringbell package as such:
import ringbell.auto
Immediate notification
If you’d like to have an immediate notification for each cell and exception.
import ringbell.immediate
All exceptions
If you’d like to have an immediate notification for all exceptions.
import ringbell.all_exceptions
Custom time interval
You can also customize the time interval as such:
from ringbell import auto_ringbell
auto_ringbell(
minimum_execution_time = 60,
only_exceptions = False,
good_sound="sample_for_nominal_execution",
bad_sound="sample_for_exceptions"
)
Usage examples
It’s quite trivia, really, just go:
from ringbell import RingBell
def my_long_task():
# Do stuf...
# And when it is finished...
RingBell(
sample = "microwave",
minimum_execution_time = 0,
verbose = True
)
How many sounds are there? Well, just list them:
from ringbell import RingBell
print(RingBell.available_samples())
What abount a custom sound? Just pass it as an argument.
from ringbell import RingBell
def my_long_task():
# Do stuf...
# And when it is finished...
RingBell(path="path/to/my_custom_sound.mp3")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ringbell-1.0.2.tar.gz
.
File metadata
- Download URL: ringbell-1.0.2.tar.gz
- Upload date:
- Size: 3.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1465301614c02414e30f6b306cf9ced802405319101677a2bbce6f284de6329 |
|
MD5 | 5e5aacd956c94aded63cd37be79a5816 |
|
BLAKE2b-256 | 163ccc4bc58b299e821e8dfa6a5aea7239c4ca8d27562286aa106e96b6597eaa |