<commit_before>import subprocess
import traceback
import uuid
import os
from dss import settings


def generate_waveform(input_file, output_file):
    working_file = "%s%s.png" % (settings.DSS_TEMP_PATH, uuid.uuid1())
    try:
        print "Starting decode : %s\n\tIn: %s\n\tOut: %s" % \
              (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_command = "%s %s -c 1 -t wav -" % (settings.DSS_LAME_PATH, input_file)
        print "Convert command: %s" % convert_command
        command_split = convert_command.split()
        convert = subprocess.Popen(command_split,
                                   stdout=subprocess.PIPE)

        waveform_command = "%s -w 800 -h 120 -o %s" % (settings.DSS_WAVE_PATH, working_file)
        waveform = subprocess.Popen(waveform_command,
                                    stdin=convert.stdout, stdout=subprocess.PIPE)

        convert.stdout.close()
        output = waveform.communicate()[0]

        print "Finished decode\n%s" % output

        if os.path.exists(working_file):
            print "Starting waveform generation"
            ret = subprocess.call([
                                      settings.DSS_WAVE_PATH, "-w", "800", "-h", "120", "-o",
                                      output_file,
                                      working_file], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
            if os.path.isfile(output_file):
                os.remove(working_file)
                print "Generated waveform"
                return output_file
            else:
                print "Failed generating waveform: %s" % output_file
                print "Subprocess returned: %s" % ret
        else:
            print "Unable to find working file, did LAME succeed?"
            return ""
    except Exception, ex:
        print "Error generating waveform %s" % (ex)
<commit_msg>Updated audio converter to use sox<commit_after>import subprocess
import traceback
import uuid
import os
from dss import settings


def generate_waveform(input_file, output_file):
    try:
        print "Starting decode : %s\n\tIn: %s\n\tOut: %s" % \
              (settings.DSS_LAME_PATH, input_file, output_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_command = "%s %s -c 1 -t wav - | %s -w 800 -h 120 -o %s /dev/stdin" % \
                          (settings.DSS_LAME_PATH, input_file, settings.DSS_WAVE_PATH, output_file)
        print "Convert command: %s" % convert_command
        result = os.system(convert_command)
        print result

        if os.path.exists(output_file):
            return output_file
        else:
            print "Unable to find working file, did LAME succeed?"
            return ""

    except Exception, ex:
        print "Error generating waveform %s" % (ex)

{'fraction_non_alphanumeric': 0.1015883520847121, 'fraction_numerical': 0.027796161482461945, 'mean_word_length': 1.943524829600779, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1964719', 'n_tokens_mistral': 1016, 'n_tokens_neox': 936, 'n_words': 237}