Sox (#48)
* update README to force python2 * add support for PRE_EMPHASIS detection; mark pre-emphasis as FLAGS PRE in .cue * correct typo, s/ivar/type/ for pre_emphasis element in track table * add SoxPeakTask, program/sox module, sox.peak_level() * use sox peak detection in lieu of gstreamer
This commit is contained in:
committed by
JoeLametta
parent
3a2e3021c2
commit
b2ca3167eb
16
morituri/program/sox.py
Normal file
16
morituri/program/sox.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import os
|
||||
import logging
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
SOX = 'sox'
|
||||
|
||||
def peak_level(track_path):
|
||||
if not os.path.exists(track_path):
|
||||
logging.warning("SoX peak detection failed: file not found")
|
||||
return None
|
||||
sox = Popen([SOX, track_path, "-n", "stat"], stderr=PIPE)
|
||||
out, err = sox.communicate()
|
||||
if sox.returncode:
|
||||
logging.warning("SoX peak detection failed: " + s.returncode)
|
||||
return None
|
||||
return float(err.split('\n')[3].split()[2]) # Maximum amplitude: 0.123456
|
||||
Reference in New Issue
Block a user