Python Forum

Full Version: Using SoX in Python to Increase mp3 Bitrate
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to increase the bitrate on an mp3 in an audio archiving program written in Python, that uses SoX.

Here's a portion of the code:

    DeltaSeconds = chunk['TimeDelta'].total_seconds()
    fullHour = (3540 < DeltaSeconds < 3660 )        
    targetMp3 = ''.join((tmpFolder, '/', str(x), '.mp3'))
    if fullHour: # no trim necesary, just convert to mp3
        # print tab,'fullHour [',str(x),']'
        # print tab,'    ','SourceOgg -> ', str(SourceOgg)
        # print tab,'    ', 'targetMp3 -> ', str(targetMp3)
        cmd = ['sox', SourceOgg, targetMp3]
        print cmd
        call(cmd)
This is what I tried:

cmd = ['sox', SourceOgg, '-C 192.2', targetMp3]
I ran this in the command line on my Ubuntu machine, and it worked perfectly:

sox old.ogg -C 192.2 new.mp3

So I believe it's something specific to running the command in python. I may be missing something with the syntax?

According to the documentation, this should work. Here is the full project: AutoCharlie

The source file is an ogg (Sample Rate 44100,Bits per sample 32, Bitrate 499 kpbs).

Any thoughts would be greatly appreciated, thanks!
Update... to make it work in an array, just had to do this:

cmd = ['sox', SourceOgg, '-C', '192.2', targetMp3]