Added a config file, no more source code editing
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
||||
*.wav
|
||||
config.json
|
||||
.vscode
|
@ -3,14 +3,27 @@ import pyaudio, numpy, keyboard, time
|
||||
import scipy.io.wavfile as wav
|
||||
from sys import getsizeof
|
||||
import os
|
||||
from os.path import exists
|
||||
import json
|
||||
import shutil
|
||||
|
||||
##### CONFIG #####
|
||||
##### CONFIG (Now read from file) #####
|
||||
|
||||
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'
|
||||
if(not exists("config.json")):
|
||||
shutil.copy("config.json.example", "config.json")
|
||||
print("No config found. Created default config")
|
||||
|
||||
with open('config.json', 'r') as myfile:
|
||||
data = myfile.read()
|
||||
|
||||
# parse file
|
||||
conf = json.loads(data)
|
||||
|
||||
RATE = conf["SampleRate"] # Sample rate
|
||||
RECORD_SECONDS = conf["SecondsToRecord"] # Seconds to record (aka. last X seconds)
|
||||
SourcesToRecord = conf["SourcesToRecord"] # Record all sources which contains these strings
|
||||
SaveDirectory= conf["SaveDirectory"]
|
||||
shortcut = conf["Shortcut"]
|
||||
|
||||
##### CONFIG END (aka. DO NOT FRICKING TOUCHY) #####
|
||||
|
||||
|
7
config.json.example
Normal file
7
config.json.example
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"SampleRate": 48000,
|
||||
"SecondsToRecord": 20,
|
||||
"SourcesToRecord": [],
|
||||
"SaveDirectory": ".",
|
||||
"Shortcut": "alt+1"
|
||||
}
|
Reference in New Issue
Block a user