diff --git a/README.md b/README.md index 7135b70..629d8ee 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,7 @@ run it. All of the converted files will be placed in a directory called `shortened` under the path you supply. Requires either an OSX or Linux environment, plus the program `ffmpeg` to be installed + +You can adjust the THRESHOLD and SIZE_LIMIT variables to change what it +considers the threshold of silence to be, and the maximum length in minutes of +what it will convert. diff --git a/slice.py b/slice.py index 03c7548..d48bb94 100755 --- a/slice.py +++ b/slice.py @@ -7,12 +7,15 @@ from sys import argv from fabric.api import * from sys import argv +THRESHOLD = 1.0 +SIZE_LIMIT = 10 + def rms(ss): return np.sqrt(np.abs(np.mean(np.square(ss)))) def findCeiling(ss, factor): slice = len(ss) - while not (rms(ss[0:slice]) < 1.2): + while not (rms(ss[0:slice]) < THRESHOLD): slice = int(len(ss)/factor) factor += 1 return slice @@ -30,7 +33,7 @@ def convert(infile): # the total number of samples total = float(len(pcm[1])) - if length <= 8: + if length <= SIZE_LIMIT: sio.write("/tmp/%s.silenced.wav" % infile, pcm[0], pcm[1][ceiling:]) local("cp /tmp/\"%s.silenced.wav\" ./shortened/\"%s.wav\"" % (infile, infile)) local("rm /tmp/\"%s.silenced.wav\"" % infile)