Added a config file, no more source code editing

This commit is contained in:
2021-06-27 12:36:07 +02:00
parent facb0a190d
commit e66f20bb68
3 changed files with 29 additions and 7 deletions

4
.gitignore vendored
View File

@ -1 +1,3 @@
*.wav
*.wav
config.json
.vscode

View File

@ -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
View File

@ -0,0 +1,7 @@
{
"SampleRate": 48000,
"SecondsToRecord": 20,
"SourcesToRecord": [],
"SaveDirectory": ".",
"Shortcut": "alt+1"
}