Compare commits
6 Commits
818ef7161a
...
XilefTech-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f45166c9b8 | ||
|
|
5d80086eab | ||
|
|
d767422d15 | ||
|
|
e5e2ba7396 | ||
| df66c6fd5a | |||
| e088f3543c |
@@ -1,12 +1,20 @@
|
|||||||
|
# Original code by TheGreydiamond Copyright 2020-2021
|
||||||
import pyaudio, numpy, keyboard, time
|
import pyaudio, numpy, keyboard, time
|
||||||
import scipy.io.wavfile as wav
|
import scipy.io.wavfile as wav
|
||||||
from sys import getsizeof
|
from sys import getsizeof
|
||||||
|
import os
|
||||||
|
|
||||||
|
##### CONFIG #####
|
||||||
|
|
||||||
|
RATE=48000 # Sample rate
|
||||||
|
RECORD_SECONDS = 20 # Seconds to record (aka. last X seconds)
|
||||||
|
SourcesToRecord = ["VoiceMeeter VAIO3 Output"] # Record all sources which contains these strings
|
||||||
|
SaveDirectory= "D:\AudioSnippetTool\Recordings"
|
||||||
|
shortcut = 'alt+1'
|
||||||
|
|
||||||
|
##### CONFIG END (aka. DO NOT FRICKING TOUCHY) #####
|
||||||
|
|
||||||
RATE=48000
|
|
||||||
RECORD_SECONDS = 20
|
|
||||||
CHUNKSIZE = 1024*2
|
CHUNKSIZE = 1024*2
|
||||||
|
|
||||||
SourcesToRecord = ["VoiceMeeter VAIO3 Output", "Aux"]
|
|
||||||
print("Searching for audio sources")
|
print("Searching for audio sources")
|
||||||
Sources = []
|
Sources = []
|
||||||
AudioChannels = []
|
AudioChannels = []
|
||||||
@@ -20,6 +28,7 @@ cleanUp = False
|
|||||||
incomingAudioChan = -1
|
incomingAudioChan = -1
|
||||||
localAudioChan = -1
|
localAudioChan = -1
|
||||||
|
|
||||||
|
## Find the acutal device pointers
|
||||||
for i in range(0, numdevices):
|
for i in range(0, numdevices):
|
||||||
if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
|
if (p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels')) > 0:
|
||||||
i2 = 0
|
i2 = 0
|
||||||
@@ -36,19 +45,32 @@ while(i <= len(SourcesToRecord)):
|
|||||||
Frames.append([])
|
Frames.append([])
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
# Save the replay
|
||||||
def on_triggered():
|
def on_triggered():
|
||||||
global cb, saves
|
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 = []
|
cutUpBuffers = []
|
||||||
i = 0
|
i = 0
|
||||||
name = time.strftime("%Y-%m-%d_%H-%M-%S-out-")
|
name = time.strftime("%Y-%m-%d_%H-%M-%S-out-")
|
||||||
while(i < len(Frames) - 1):
|
while(i < len(Frames) - 1):
|
||||||
|
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:]))
|
wav.write(name + str(saves) + str(i) + '.wav', RATE, numpy.hstack(Frames[i][-320:]))
|
||||||
i += 1
|
i += 1
|
||||||
saves+=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)
|
keyboard.add_hotkey(shortcut, on_triggered)
|
||||||
|
|
||||||
print(" There are " + str(len(SourcesToRecord)) + " SourcesToRecord. Frames: " + str(len(Frames)))
|
print(" There are " + str(len(SourcesToRecord)) + " SourcesToRecord. Frames: " + str(len(Frames)))
|
||||||
|
|||||||
Reference in New Issue
Block a user