Added a config file, no more source code editing
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@ -1 +1,3 @@
|
|||||||
*.wav
|
*.wav
|
||||||
|
config.json
|
||||||
|
.vscode
|
@ -3,14 +3,27 @@ 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
|
import os
|
||||||
|
from os.path import exists
|
||||||
|
import json
|
||||||
|
import shutil
|
||||||
|
|
||||||
##### CONFIG #####
|
##### CONFIG (Now read from file) #####
|
||||||
|
|
||||||
RATE=48000 # Sample rate
|
if(not exists("config.json")):
|
||||||
RECORD_SECONDS = 20 # Seconds to record (aka. last X seconds)
|
shutil.copy("config.json.example", "config.json")
|
||||||
SourcesToRecord = ["VoiceMeeter VAIO3 Output"] # Record all sources which contains these strings
|
print("No config found. Created default config")
|
||||||
SaveDirectory= "D:\AudioSnippetTool\Recordings"
|
|
||||||
shortcut = 'alt+1'
|
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) #####
|
##### 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