Merge addition of save location config option #1

Merged
grey merged 4 commits from XilefTech-Edits into central 2021-06-27 12:25:55 +02:00
Showing only changes of commit d767422d15 - Show all commits

View File

@@ -2,11 +2,13 @@
import pyaudio, numpy, keyboard, time
import scipy.io.wavfile as wav
from sys import getsizeof
import os
##### CONFIG #####
RATE=48000 # Sample rate
RECORD_SECONDS = 20 # Seconds to record (aka. last X seconds)
SaveDirectory= "D:\AudioSnippetTool\Recordings"
grey marked this conversation as resolved Outdated
Outdated
Review

Don't commit your personal path please.

Don't commit your personal path please.

what do you want to have as a "default" path then?

what do you want to have as a "default" path then?
Outdated
Review

Doesn't matter, I have an idea what to implment just forget about it.

Doesn't matter, I have an idea what to implment just forget about it.
shortcut = 'alt+1'
XilefTech marked this conversation as resolved Outdated
Outdated
Review

Why excatly did you remove this?

Why excatly did you remove this?

was a mistake will re-add it

was a mistake will re-add it
##### CONFIG END (aka. DO NOT FRICKING TOUCHY) #####
@@ -45,17 +47,29 @@ while(i <= len(SourcesToRecord)):
# Save the replay
def on_triggered():
global cb, saves
print("Saving replay..", end = "")
print("Saving replay...")
# save current working directory and switch to saving path
cwd = os.getcwd()
os.chdir(SaveDirectory)
# save the audio
cutUpBuffers = []
i = 0
name = time.strftime("%Y-%m-%d_%H-%M-%S-out-")
while(i < len(Frames) - 1):
wav.write(name + str(saves) + str(i) + '.wav',RATE,numpy.hstack(Frames[i][-320:]))
print("Saving file: " + name + str(saves) + str(i) + '.wav', "to", os.getcwd())
wav.write(name + str(saves) + str(i) + '.wav', RATE, numpy.hstack(Frames[i][-320:]))
i += 1
saves+=1
print("[DONE]")
shortcut = 'alt+1'
# return back to original working directory
os.chdir(cwd)
print("Saving done")
# add the keyboard hotkey listener
keyboard.add_hotkey(shortcut, on_triggered)
print(" There are " + str(len(SourcesToRecord)) + " SourcesToRecord. Frames: " + str(len(Frames)))