Skip to content

Commit fe2c33a

Browse files
authored
Merge pull request #588 from sighclone/Audio-Sticky-Notes
Audio sticky notes
2 parents 852051f + 53a192a commit fe2c33a

File tree

5 files changed

+126
-0
lines changed

5 files changed

+126
-0
lines changed

audio_sticky_notes/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## About
2+
This script allows you to maintain voice note based desktop sticky notes.
3+
4+
### Setup Modules
5+
You need the following modules to run the program
6+
7+
```pip install -m sounddevice```<br>
8+
```pip install -m soundfile```
9+
10+
11+
### Instructions
12+
The base window just consists of an option to create a new audio sticky note or to reset the sticky notes. You can click on `New+` to create a new audio sticky note and the `Reset-` to clear all notes, be sure to restart the program on reset!
13+
By creating a new note, you get the note's window with a few options. Under the `Record for: (secs)` section, you can choose how long do you want to record the note. Below that is the `Playback:` section where you can click the button to listen to the previously recorded audio note. For a more sticky note like experience you might want to add the program to your startup folder!
14+
15+
### Working Screenshots
16+
![image](https://user-images.githubusercontent.com/12183499/135730272-503b3e29-31f9-498d-b554-f8ea7fe9c4a3.png)<br>
17+
![image](https://user-images.githubusercontent.com/12183499/135730300-0d4e4a45-7e44-45a4-9f05-3f41d04374ef.png)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
placeholder created to ensure github accepts the directory names

audio_sticky_notes/main.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import tkinter
2+
import subprocess
3+
4+
5+
def makenew():
6+
maker(numofwindows)
7+
8+
9+
def maker(wins):
10+
global numofwindows
11+
subprocess.Popen(["python.exe", "note.py", str(numofwindows)], shell=True)
12+
numofwindows = 1 + wins
13+
maintain()
14+
15+
16+
def maintain():
17+
global numofwindows
18+
storage = open("assets\\storage", "w")
19+
storage.write(str(numofwindows))
20+
storage.close()
21+
22+
23+
def reset():
24+
storage = open("assets\\storage", "w")
25+
storage.write(str(0))
26+
storage.close()
27+
28+
29+
try:
30+
getwin = open("assets\\storage", "r")
31+
win = getwin.readline()
32+
numofwindows = int(win)
33+
getwin.close()
34+
for i in range(0, numofwindows):
35+
subprocess.Popen(["python.exe", "note.py", str(i)], shell=True)
36+
except FileNotFoundError:
37+
numofwindows = 0
38+
39+
manager = tkinter.Tk()
40+
manager.title("Audio Notes - Master")
41+
42+
while True:
43+
try:
44+
makeNewBtn = tkinter.Button(manager, text='New+', command=makenew)
45+
makeNewBtn.pack()
46+
reset = tkinter.Button(manager, text='Reset-', command=reset)
47+
reset.pack()
48+
tkinter.mainloop()
49+
except tkinter.TclError:
50+
break

audio_sticky_notes/note.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import tkinter
2+
import sounddevice as sd
3+
import soundfile as sf
4+
import sys
5+
6+
7+
def rec10s():
8+
rec(10)
9+
10+
11+
def rec5s():
12+
rec(5)
13+
14+
15+
def rec15s():
16+
rec(15)
17+
18+
19+
def rec(duration):
20+
fs = 48000
21+
22+
recording = sd.rec(int(duration * fs), samplerate=fs, channels=2)
23+
sd.wait()
24+
25+
return sf.write("assets\\recordings\\AudioNote{}.flac".format(str(sys.argv[1])), recording, fs)
26+
27+
28+
def playback():
29+
filename = "assets\\recordings\\AudioNote{}.flac".format(str(sys.argv[1]))
30+
data, fs = sf.read(filename, dtype='float32')
31+
sd.play(data, fs)
32+
sd.wait()
33+
34+
35+
master = tkinter.Tk()
36+
master.title("Audio Note {}".format(str(sys.argv[1])))
37+
38+
tkinter.Label(master, text=" Record for: (sec) ").grid(row=0, sticky=tkinter.W, rowspan=5, padx=15)
39+
40+
b = tkinter.Button(master, text="5", command=rec5s)
41+
b.grid(row=0, column=2, columnspan=2, rowspan=2, padx=10, pady=10)
42+
43+
c = tkinter.Button(master, text="10", command=rec10s)
44+
c.grid(row=0, column=4, columnspan=2, rowspan=2, padx=10, pady=10)
45+
46+
d = tkinter.Button(master, text="15", command=rec15s)
47+
d.grid(row=0, column=6, columnspan=2, rowspan=2, padx=10, pady=10)
48+
49+
tkinter.Label(master, text=" Playback: ").grid(row=5, sticky=tkinter.W, rowspan=5, padx=15)
50+
51+
e = tkinter.Button(master, text="Listen to the note", command=playback)
52+
e.grid(row=5, column=3, columnspan=5, padx=10, pady=10)
53+
54+
tkinter.Label(master, text=" ").grid(row=10, sticky=tkinter.W, rowspan=5)
55+
56+
tkinter.mainloop()

audio_sticky_notes/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sounddevice==0.4.2
2+
soundfile==0.10.3.post1

0 commit comments

Comments
 (0)