Python / Audio Conversion - I want to convert mp3 to wav

Hi, Ive dabbled very little in actual coding, wrote one python app that these forums really helped me make, and Ive programmed in VBScript and SQL Server, but all academic, nothing for my own uses.  I need a program to convert mp3's to .wav's that can then be burned in 'Recorder' to burn the audio disc.  I know there are many scripts like this floating around, but I want to do my own, problem is, im lost.  I seem to have 2 main problems, getting the file names into a list or tuple,  and then actually running the commands to convert using a for loop using lame or mpg321.
this bash script uses mpg321 and sox,
#!/bin/bash
# allmp3wav
for i in *.mp3; do
echo "$i"
tgt=$(echo "$i" | sed -e "s/mp3/wav/")
mpg123 -b 10000 -s -r 44100 "$i" | sox -t raw -r 44100 -s -w -c2 - /var/cdrom/"$tgt"
done
This works fine and I understand the code.  Its saying for every file that ends in .mp3, run these commands, which do the coding.  The only problem is, this doesnt work in python, since its not pythong   Can someone give me a little bit of help?  Dont give me the program, or give me to much info, links would be great.
1 - Need to Get Directory
2 - Loop through all the .mp3 files and add them to an array.
3 - create a sub directory named "wav"
mkdir ~/wav
4 - copy all the mp3's to "wav"
cp ARRAy to wav/
5 - convert all .mp3's to wav
6 - delete the copied mp3's from .wav directory
for .mp3
rm
7 - tell me how many wavs were created.
for .wav
count + 1
That is just a rough flow chart of what I need to do, and as you can see its pretty bare as of now.  Also, I imagine to run mpg321 or lame commands, I need some sort of lame or mpg321 module?  Ive read the python wiki for for loops and lists and tuples, but I need more info.  Thanks, Justin.

Alright that helped alot, its almost working now, I am using Popen wrong still I assume, here is what I got.
import os
import subprocess
here = os.getcwd()
ctr = 0
for file in os.listdir(here):
    name, ext = os.path.splitext(file)
    if ext == ".mp3":
                p = subprocess.Popen("mpg123 -w " + name + ".wav " + name + ext , stdout=subprocess.PIPE, shell=True)
                ctr = ctr + 1
print ctr
That executes, but gives this error,
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
version 1.4.3; written and copyright by Michael Hipp and others
free software (LGPL/GPL) without any warranty but with best wishes
[readers.c:893] error: Cannot file [Beginning: No such file or directory
[mpg123.c:516] error: Cannot open [Beginning: File access error. (code 22)
[readers.c:893] error: Cannot file of: No such file or directory
[mpg123.c:516] error: Cannot open of: File access error. (code 22)
[readers.c:893] error: Cannot file Whats About to Happen] HWY 74.wav 01 [Beginni
ng of Whats: No such file or directory
[mpg123.c:516] error: Cannot open Whats About to Happen] HWY 74.wav 01 [Beginnin
g of Whats: File access error. (code 22)
[readers.c:893] error: Cannot file About: No such file or directory
[mpg123.c:516] error: Cannot open About: File access error. (code 22)
[readers.c:893] error: Cannot file to: No such file or directory
[mpg123.c:516] error: Cannot open to: File access error. (code 22)
[readers.c:893] error: Cannot file Happen]: No such file or directory
[mpg123.c:516] error: Cannot open Happen]: File access error. (code 22)
[readers.c:893] error: Cannot file HWY: No such file or directory
[mpg123.c:516] error: Cannot open HWY: File access error. (code 22)
[readers.c:893] error: Cannot file 74.mp3: No such file or directory
[mpg123.c:516] error: Cannot open 74.mp3: File access error. (code 22)
2
If i remove the subprocess popen, and just print name + ext and use the counter, it prints out both file name together, and how many mp3's it processed, 2.  So i know the program is doing what I want, im just converting wrong.  Thanks again.
here is whats in the directory, there is more then mp3's, so I know it is filtering the files properly thanks to your splittext.
justin ~/build/convert $  dir -ls
total 12104
  20 -rw-r--r-- 1 justin justin   17138 2008-05-19 17:59 00\ -\ Wretch.txt
   4 -rw-r--r-- 1 justin justin      44 2008-06-01 18:20 01
7588 -rw-r--r-- 1 justin justin 7768364 2008-05-19 17:59 01\ [Beginning\ of\ What's\ About\ to\ Happen]\ HWY\ 74.mp3
   4 -rw-r--r-- 1 justin justin      44 2008-06-01 18:20 02
4484 -rw-r--r-- 1 justin justin 4588063 2008-05-19 17:59 02\ Love\ Has\ Passed\ Me\ By.mp3
   4 -rw-r--r-- 1 justin justin    1284 2008-06-01 18:20 convert.py
justin ~/build/convert $
Last edited by axion419 (2008-06-01 22:23:32)

Similar Messages

  • Convert mp3 to Wav?

    Hi, i'm looking for a software that would allow me to convert mp3 to wav files. I have to upload files but the source only accepts wav files and I can't get itunes to export to wav format so your help would be much appreciated.

    I've used EasyWMA to convert audio formats before, and it may be able to do what you want. There is a limited free trial available:
    http://www.easywma.com/
    You can also try searching versiontracker.com or macupdate.com with the file types to see if there is other conversion software available.

  • Want to convert in to wav file !

    i'm working on the project which is about to generate WAV file from RTP (real-time protocol) packets.
    Basically, this program should read packets from a data file (PCAP
    format) that contains RTP packets for a VoIP stream and then
    convert it to WAV file which can be played in Media player.
    as you are very experince developer can you guide me how could i do it.or where to start?

    i think you can create a Processor that gets an url as input locator or that creates an RTP session an listens for the input stream. To convert to wav, just take processor track control and content descriptor or file type descriptor and adjust them to convert to wav format (AudioFormat). To write to a file, set the rigth locator.
    good example of writting and changing format:
    http://java.sun.com/products/java-media/jmf/2.1.1/guide/JMFCapturing.html#93821

  • Downloaded audio book and want to convert to Mp3 ideas?

    Cant figure out how to convert the songs and Audio books i bought and downloaded to MP3 format for my Blackberry or any MP3 player for the matter.  I also wanted to know if anyone knew how to expant the 5 share thing due to the fact my daughter my wife and myself all have laptops and MP3 players so in my world that makes 6 any ideas would be appreciated I am new to this I tunes still learning.
    Thanks Tom

    I would have to look at it when I get home at work now I tried for 3 hours today and could not get it to load on my phone.  I have always been a BB freak but seriously looking at I phones now my first step was this I tunes just started yesterday so forgive me if I am not that savy.....................yet

  • Can jmf broadcast mp3 files?convert mp3 to wav format to enable streaming?

    Hello... can jmf broadcast mp3 file format audio files.. so that it can accessible.. since it is playable... or does it require conversion to another for in audio in order for it to be streamed on LAN... Thanks and more power to JAVA..

    Man, have you ever opened Logic before? If you had you would have noticed that these instructions are for Logic and yes you will obtain 44.1/16 files if you choose these options in the "copy/convert" menue.

  • Converting mp3 to wave fi

    hi gang
    just to refresh my mind what is the procedure for convewrting mp3 files(from a store bought cd )to wave
    filesi no how to use the converter but afterr i use it the file is still in mp3 format.what am i doing wrong?any ideas?
    coonsanders

    hi
    thanks 4 your reply but i want to use the organizer so lets not confuse things.
    xcoonsanders

  • Audio Recording - Conversion from .caf files to mp3 / flv

    Hi,
    Does anybody has done any dynamic audio conversion from .caf files to mp3 or flv format? Basically we have an Iphone app that is recording audio and it saves the data in a SQL Server Database but we want to share this audio in a website. The website need to be able to play the audio in Flash. Does this make sense? I've seen some libraries out there but the Services and Environment are running on Windows so the conversion may be need to be on that environment.
    Thanks,

    The .cda files you see on the CD are a red herring. Bet you any money you're using Windows. :-)
    Besides that, this question has absolutely nothing to do with Collections.

  • .mp3 to .wav conversion

    Hi All Genius
    I want to convert .mp3 files into .wav files.
    Is it possible if yes then how?
    Will anybody help me out?
    regards,
    Anil R

    Thanks prometheuzz.You're welcome.
    @other posters, new thread started in the sound-forum:
    http://forum.java.sun.com/thread.jspa?threadID=5205336

  • How to convert .MP3 files into .AAC with iTunes 10.5.2

    Im running a Mac OS X 10.5.8, and my iTunes version is 10.5.2.
    I want to convert .MP3 files into .AAC using iTunes, but no option is given for me. What should I do?

    im not going to change all my songs into AAC, I was experiementing around with making ringtones for my iphone. I can open a song in Garageband, and export it as an AAC file to my itunes, but it is very annoying. I remember older versions of itunes having a "Convert to AAC" option, but i can't find it anymore on this current version of itunes.
    Basically, I want to convert a couple songs into AAC to create ringtones out of them.

  • Convert mp3 wav

    How do I convert an mp3 file to wav in labview? Using active X with another program, or whatever. Anyone have any examples made?
    Why can't NI just include sound vi's that use mp3 just as it does wav? Wav is impractical.
    Thx.

    Wave isn't impractical. Most compressed audio formats are lossy. The sound is good enough for the human ear, but might not be appropriate for the application.
    MP3 is a licensed format and to use it NI would probably have to pay the owners (Fraunhofer, I think) quite a lot of money.
    I don't know if you'll find any exposed ActiveX interface for converting mp3 to wave. The more likely possibilities are a DLL or a .Net class. I would try searching Google for DLLs providing this functionality and then see if you can call them in LV.
    Try to take over the world!

  • How to convert mp3 to podcast

    I want to convert mp3 files, (lectures) as podcasts to play them on the iphone. The iphone just imports them into music and plays them as songs on the iphone. Just changing the Options to podcast, in the info section doesn't change it on the iphone, only in itunes on the mac?

    Here is the answer that works well. The instructions may seem long, but it really isn't hard to do once you've tried it.
    To make mp3 files into podcasts:
    First, in itunes, find the mp3 file(s) in the music section, and hit edit, then delete. It will tell you that
    it will remove it from itunes and the iphone, click OK.
    Then it will ask you if you want to put the file in the trash or keep the file
    in the music folder. Keep the file. This will remove it from itunes, and the iphone, which is what you want.
    Second, open up a finder window on the mac. Navigate to the itunes music folder,
    which is in machd/users/johnsmith/music/itunes/itunes music. Then open another finder window alongside the one that is showing the itunes music folder. In that finder window, create a unique named new folder on the desktop, such as "movedmusic". Now, go to the itunes music folder and drag the mp3 file over to the "movedmusic" folder and drop it there. Now, the mp3 file is no longer in itunes at all.
    Third, go back to itunes main screen, click File, then "add to library". It will open a mini finder window of it's own. Navigate to the "movedmusic" folder you created on your desktop and select the mp3 file, and let it import into itunes.
    Don't worry about where itunes puts it. iTunes will put it in "songs", but that is ok. It is still seen as "new" to itunes.
    Fourth, go to the "music" at the top left of itunes menu. Find the newly imported mp3 file. Right click and select "get info". Open "options" and change it from "music" to "podcast" and hit OK. Now, you will see it disappear from the main screen in music. Go to podcasts on the left menu, and it will now be in podcasts. But WAIT! There is one more step to do or it won't sync to your iphone. Now go to the iphone on the left hand menu and select it under "devices". Then go to the iphone's "podcasts" tab, and you'll see the mp3 file you just added as a podcast. Make sure you put a check in the checkbox, that will tell itunes to sync your newly added mp3 PODCAST to your iphone. Then go over to File at the top of itunes and select "sync iphone". After the iphone syncs, your mp3 will be on your iphone in the podcast menu, and not in the songs menu!

  • Mp3 to wav converter

    i am looking for mp3 to wav converter Api (in j2me) how it can be done help needed plz it 's urgent !
    hoping for an early reply

    no way!
    you've got a java api for j2se: the javasound api but it can't be available in j2me. best thing to do is to use a soft (like cdex,...) to convert mp3 to wav or, if you have an available server (like tomcat), create a app that uses javasound api to convert your songs when you put them on the server (via an admin console)
    peace

  • MP3 to WAV Codec in Processor

    Hi,
    I�m trying to add Codec to an processor because I want convert MP3 to WAV.
    When y obtain PlugInManager.getPlugInList (with type=4) only obtain com.ibm.media.codec.audio.ACMCodec.
    After make processor.realize(), I inspect the processor CodecChain (before I have added the ACMCodec when processor was in Configured state). But when I inspect the supportedOutputFormat and supportedInputFormat of ACMCodec, don�t find MP3 anywhere.
    What am I doing wrong?, Have I install any codec for ACM?, Are There any Plug-in for MP3 to WAV??
    thanks.
    Message was edited by:
    ivan1978

    Hi,
    I�m trying to add Codec to an processor because I want convert MP3 to WAV.
    When y obtain PlugInManager.getPlugInList (with type=4) only obtain com.ibm.media.codec.audio.ACMCodec.
    After make processor.realize(), I inspect the processor CodecChain (before I have added the ACMCodec when processor was in Configured state). But when I inspect the supportedOutputFormat and supportedInputFormat of ACMCodec, don�t find MP3 anywhere.
    What am I doing wrong?, Have I install any codec for ACM?, Are There any Plug-in for MP3 to WAV??
    thanks.
    Message was edited by:
    ivan1978

  • Automator For Mp3 to WAV

    I was wondering if anyone out there familiar with Automator knew of a way to automate converting MP3s to WAVs. It would be nice to just cntl click on an MP3 and have the automator open qiucktime and convert the audio file to wave. I never use automator but it seems like something someone would have already figured out how to work. Thanks for any help

    no way!
    you've got a java api for j2se: the javasound api but it can't be available in j2me. best thing to do is to use a soft (like cdex,...) to convert mp3 to wav or, if you have an available server (like tomcat), create a app that uses javasound api to convert your songs when you put them on the server (via an admin console)
    peace

  • It's 2013 and I want to convert AIFF audio files to MP3s

    It’s 2013 and I want to convert .AIFF audio files to .MP3 files on my Mac.
    I created some sound files as .MOVs for a band’s website but that format doesn’t work for some Windows OS users who refuse to fetch a QuickTime plugin for their Explorer or Firefox internet browser…("don’t make them think; it either works or it doesn’t.")
    I have been told that MP3 audio files are still the most common audio files on the web and I want the band’s music to be in the most-accessible format.
    Thanks,
    Ron
    Also, this is my first Apple Support question and I would appreciate being pointed to the most appropriate forum(s).

    Thanks, Joe, that was very useful!
    For other people with my problem I should add some of the missing puzzle pieces —
    1) A while ago I loaded the songs from the band’s CD onto a previous, now dead, Mac laptop (with a previous Mac OS) and used QuickTime 7 to create down-sampled (and smaller) .mov files. Then I deleted the original .aif files from that computer.
    2) Now (back to the present) I wanted the .aif audio files on my new computer to convert them, but the computer doesn’t have a CD/DVD drive. My solution was to use my partner’s iMac.
    3) I inserted the CD into the iMac’s drive, clicked "no" to iTunes’ dialog asking if I wanted to import them, created a folder on the desktop, then opened the CD folder on the desktop and copied the songs into the newly-created folder.
    4) I copied the new .aif files to a thumbdrive then deleted the .aifs from the iMac.
    5) I put the copied thumbdrive .aif songs onto my MacBook Pro Retina (where I had changed iTunes Preferences to MP3) then I 'dropped' the sound file icons onto the iTunes icon in the dock.
    5) In iTunes I right-clicked on the songs and chose "Create MP3 Version".
    6) Next, I right-clicked on the MP3s in iTunes and chose "Show in Finder". This opened another folder (~/Music/iTunes/iTunes Media/Music/Unknown Artist/Unknown Album/), revealing the MP3s.
    7) I created duplicates of the MP3s and moved them to my band's media folder (and will put them on the website after renaming them and editing their webpage for the new audio filenames).
    8) Finally, I will delete the .aif and .mp3 songs from my iTunes, using iTunes' interface to ensure it doesn’t get confused.
    Sheesh. but I’m still happy to not have a CD/DVD drive on my MacBook Pro. I very rarely use CDs and a drive on the laptop would add bulk and weight while being mostly useless.

Maybe you are looking for

  • Black video screen on tv

    untill recently i have had no problems playing out video to my tv (connected through a vcr as no scart socket) i tried last night to play one (after a month or so since the last time i played one to my tv) the desktop was displyed perfectly but in my

  • Main screen and dock move to second display

    Hi all, although i found many replies regarding to how to get the dock to the desired screen i face the following problem. I am a vj/dj using serato dj, mix emergency and madmapper. Whenever i connect a second display to my macbook (macbook pro early

  • Single Page Spry Tabbed Insert - Delete - Update

    Hi Guys I like to make a page with three Spry Tabs. * Using ( PHP - Mysql ) * Example ( Table of "Users" Fields ID, Name, Age ) ( First Tab ) List of all people with navigation dividing table by ten rows each time. On each row Delete & Update This pe

  • IOS7 - not so good right now.

    Downloaded the IOS7 on a iphone 4s. When deleting voicemail my phone will freeze and/or the deleted voicemail will reappear. This is not an intermittent problem it occurs on  a regular basis and also can't pause a voicemail deleted.

  • Robohelp keeps crashing

    I installed RoboHelp 8.0.2.208 last year and have a couple of hundred topics and images (most are icon sized PNG and GIFs). Whenever I open a topic that contains images, RoboHelp will often crash and exit (no error messages). This is super annoying a