-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from Sangarshanan/add-success-tracks
Add onsuccess tracks
- Loading branch information
Showing
8 changed files
with
285 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# JazzIt 🎷 | ||
|
||
[![Open All Collab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/Sangarshanan/jazzit/blob/master/notebook.ipynb) | ||
[![License](https://img.shields.io/pypi/l/jazzit.svg)](https://github.com/Sangarshanan/jazzit/blob/master/LICENSE) | ||
[![Say Thanks!](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg)](https://saythanks.io/to/[email protected]) | ||
|
||
Ever wanted your scripts to play music while running/ on erroring out? | ||
|
||
Of course you didn't | ||
|
@@ -64,26 +68,95 @@ if __name__ == "__main__": | |
run(1000) | ||
``` | ||
|
||
The in-build tracks are bruh_moment, elevator and curb_your_enthusiasm but you can add your custom tracks | ||
To satisfy your WHAT !!! IT WORKED !!! moments | ||
|
||
|
||
```python | ||
from jazzit import success_track | ||
|
||
@success_track("anime-wow.mp3") | ||
def add(a,b): | ||
print(a+b) | ||
|
||
if __name__ == "__main__": | ||
add(12, 42) | ||
``` | ||
|
||
The in-build tracks are bruh_moment, elevator and curb_your_enthusiasm but you can add your custom tracks and urls | ||
|
||
Check out some of the [examples](https://github.com/Sangarshanan/jazzit/tree/master/examples) | ||
|
||
|
||
> :warning: **Use wisely**: Best suited for scripts you run non-professionally! | ||
### Jupyter Notebook | ||
|
||
Check out the colab link above or the example [notebook](https://github.com/Sangarshanan/jazzit/blob/master/notebook.ipynb) | ||
|
||
### Use Jupyter Magic: | ||
|
||
Load inside a Jupyter notebook | ||
|
||
``` python | ||
%load_ext jazzit | ||
``` | ||
|
||
Running away from the PEP8 police 🚲🚓 | ||
|
||
```python | ||
%%waiting_track -t elevator.mp3 | ||
|
||
def fibonacci(n): | ||
if n < 0: | ||
raise Exception("BE POSITIVE!!!") | ||
elif n == 1: | ||
return 0 | ||
elif n == 2: | ||
return 1 | ||
else: | ||
return fibonacci(n - 1) + fibonacci(n - 2) | ||
for num in range(1, 35): | ||
print(fibonacci(num)) | ||
``` | ||
|
||
For those BRUH moments in your life | ||
|
||
```python | ||
%%error_track -t bruh.mp3 -w 3 | ||
|
||
for num in reversed(range(10)): | ||
print(10/num) | ||
``` | ||
|
||
It worked !!! | ||
|
||
```python | ||
%%success -t anime-wow.mp3 -w 3 | ||
|
||
for num in range(10): | ||
print(num ** 2) | ||
``` | ||
|
||
There are two arguments in play here | ||
|
||
`-t` or `--track` that needs the sound track (Can be a file path, url, inbuilt tracks) | ||
|
||
`-w` or `--wait` (Optional, default is 3 seconds) Wait for x seconds before cutting the music | ||
|
||
|
||
### Dependencies | ||
|
||
Jazz added with [playsound](https://github.com/TaylorSMarks/playsound) | ||
|
||
If you are ubuntu and getting hit with `ModuleNotFoundError: No module named 'gi` | ||
If you getting hit with `ModuleNotFound` errors while running jazzit | ||
|
||
You might need to install Pygobject https://pygobject.readthedocs.io/en/latest/getting_started.html | ||
|
||
|
||
> :warning: **Use wisely**: Best suited for scripts you run non-professionally! | ||
|
||
### Profiling | ||
|
||
TL;DR It is definitely slower with music | ||
|
||
I did a lil profiling on bin/profiler.py | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.