File: trim.py

package info (click to toggle)
asahi-audio 3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,148 kB
  • sloc: makefile: 43; python: 27
file content (12 lines) | stat: -rw-r--r-- 307 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
import sys, numpy, scipy

EPSILON = 1e-10 # -200dB

rate, data = scipy.io.wavfile.read(sys.argv[1])

count = len(numpy.trim_zeros((abs(data) > EPSILON), "b"))
data = data[:count]
count = len(numpy.trim_zeros((abs(data) > EPSILON), "f"))
data = data[-count:]

scipy.io.wavfile.write(sys.argv[2], rate, data)