mirror of
https://github.com/fergalmoran/dss.git
synced 2025-12-26 11:37:33 +00:00
Initial commit after change to backbone/SPA
This commit is contained in:
36
core/utils/waveform.py
Normal file
36
core/utils/waveform.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import subprocess
|
||||
import traceback
|
||||
import uuid
|
||||
import os
|
||||
from dss import settings
|
||||
|
||||
__author__ = 'fergalm'
|
||||
|
||||
def generate_waveform(input_file, output_file):
|
||||
print "Generating waveform"
|
||||
try:
|
||||
working_file = "%s%s.wav" % (settings.DSS_TEMP_PATH, uuid.uuid1())
|
||||
try:
|
||||
print "Starting decode : %s\nInput File: %s\nOutput File: %s" % (settings.DSS_LAME_PATH, input_file, working_file)
|
||||
p = subprocess.call([settings.DSS_LAME_PATH, "--decode", input_file, working_file])
|
||||
print "Finished decode"
|
||||
if os.path.exists(working_file):
|
||||
print "Starting waveform generation"
|
||||
print "%s -m -l -i %s -o -b 000000 %s" % (settings.DSS_WAVE_PATH, working_file, output_file)
|
||||
subprocess.call([settings.DSS_WAVE_PATH, "-t", "-m", "-l", "-i", working_file, "-o", output_file])
|
||||
|
||||
if os.path.isfile(output_file):
|
||||
os.remove(working_file)
|
||||
print "Generated waveform"
|
||||
return output_file
|
||||
else:
|
||||
print "Failed generating waveform: %s" % output_file
|
||||
else:
|
||||
print "Unable to find working file, did LAME succeed?"
|
||||
return ""
|
||||
except Exception, ex:
|
||||
print "Error generating waveform %s" % (ex)
|
||||
|
||||
except:
|
||||
print "Error generating waveform"
|
||||
traceback.print_exc()
|
||||
Reference in New Issue
Block a user