Change to SOX

This commit is contained in:
Fergal Moran
2014-03-13 19:42:09 +00:00
parent b06b0dc91b
commit 5d0612e037
3 changed files with 18 additions and 10 deletions

View File

@@ -4,13 +4,21 @@ import uuid
import os import os
from dss import settings from dss import settings
def generate_waveform(input_file, output_file): def generate_waveform(input_file, output_file):
print "Generating waveform" print "Generating waveform"
try: try:
working_file = "%s%s.wav" % (settings.DSS_TEMP_PATH, uuid.uuid1()) working_file = "%s%s.wav" % (settings.DSS_TEMP_PATH, uuid.uuid1())
try: try:
print "Starting decode : %s\nInput File: %s\nOutput File: %s" % (settings.DSS_LAME_PATH, input_file, working_file) print "Starting decode : %s\nInput File: %s\nOutput File: %s" % \
p = subprocess.call([settings.DSS_LAME_PATH, "--decode", input_file, working_file]) (settings.DSS_LAME_PATH, input_file, working_file)
#sox f679a81a-ea14-4385-a677-c663559d1e4b.mp3 -c 1 -t wav -
#| /srv/dss/bin/wav2png -w 800 -h 120 -o song.png /dev/stdin
convert = subprocess.Popen("%s %s -c 1 -t wav" % (settings.DSS_LAME_PATH, input_file),
shell=True, stdout=subprocess.PIPE)
waveform = subprocess.Popen("%s -w 800 -h 120 -o %s" % (settings.DSS_WAVE_PATH, working_file),
shell=True, stdout=subprocess.PIPE)
print "Finished decode" print "Finished decode"
if os.path.exists(working_file): if os.path.exists(working_file):
print "Starting waveform generation" print "Starting waveform generation"

View File

@@ -3,7 +3,7 @@ import os
DEBUG = True DEBUG = True
if os.name == 'posix': if os.name == 'posix':
DSS_TEMP_PATH = "/tmp/" DSS_TEMP_PATH = "/tmp/"
DSS_LAME_PATH = "lame" DSS_LAME_PATH = "sox"
DSS_WAVE_PATH = "wav2png" DSS_WAVE_PATH = "wav2png"
else: else:
DSS_TEMP_PATH = "d:\\temp\\" DSS_TEMP_PATH = "d:\\temp\\"

View File

@@ -1,7 +1,5 @@
import os import os
from django.core.files.storage import FileSystemStorage
from django.core.management.base import NoArgsCommand from django.core.management.base import NoArgsCommand
from dss import settings
from spa.models.mix import Mix from spa.models.mix import Mix
from core.tasks import create_waveform_task from core.tasks import create_waveform_task
@@ -17,12 +15,14 @@ class Command(NoArgsCommand):
if not os.path.isfile(processed_file): if not os.path.isfile(processed_file):
cached_file = mix.get_cache_path() cached_file = mix.get_cache_path()
if not os.path.isfile(cached_file): if not os.path.isfile(cached_file):
print "File for [%s] not found tried\n\t%s\n\t%s" % (mix.title, processed_file, cached_file) print "File for [%s] not found tried\n\t%s\n\t%s" % \
(mix.title, processed_file, cached_file)
return return
else:
print "File found, starting waveform task (%s)" % mix.uid print "File found, starting waveform task (%s)" % mix.uid
create_waveform_task.delay(in_file=cached_file, uid=mix.uid) create_waveform_task.delay(
print "Task submitted" in_file=cached_file, uid=mix.uid)
print "Task submitted"
except Exception, ex: except Exception, ex:
print "Error generating waveform: %s" % ex.message print "Error generating waveform: %s" % ex.message