Browse Source

add tweakable variables

master
wes 7 years ago
parent
commit
afaf99553f
  1. 4
      README.md
  2. 7
      slice.py

4
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.

7
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)

Loading…
Cancel
Save