Finding the length of an mp3 file
You can use mutagen to get the length of the song (see the tutorial): from mutagen.mp3 import MP3 audio = MP3(“example.mp3”) print(audio.info.length)
You can use mutagen to get the length of the song (see the tutorial): from mutagen.mp3 import MP3 audio = MP3(“example.mp3”) print(audio.info.length)
OK, thanks to all of you but I needed to play mp3 from byte[] as I get that from .NET webservice (don’t wish to store dynamically generated mp3s on server). In the end – there are number of “gotchas” to play simple mp3… here is code for anyone who needs it: private MediaPlayer mediaPlayer = … Read more
Pure Java Look into Tritonus’s clean room implementation of javasound which offers an MP3 encoder plugin here: http://www.tritonus.org/plugins.html Secondly, I would suggest looking into jzoom’s libraries JLayer or JLayerME: http://www.javazoom.net/javalayer/javalayer.html (this may only be decode, not sure) If those doesn’t suit your need you can look at this article from 2000 about adding MP3 capabilities … Read more
The best place to put such .mp3 or any other files would be in the assets folder. These files once stored will become a part of your android app itself and can be read easily. This tutorial describes it well. AssetFileDescriptor afd = getAssets().openFd(“AudioFile.mp3”); MediaPlayer player = new MediaPlayer(); player.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength()); player.prepare(); player.start(); Alternatively you can … Read more
JLayer should do everything you need. It’s not dead, it’s just stable. The author finished it up quite a long time ago and the MP3 format has not seen much change since. You’ll notice that his MP3SPI codebase is a little more recent. What MP3SPI does, is that translates JLayer’s abilities into JavaSound APIs. Thus … Read more
I’m not on a Mac right now, so I can’t test, but this page suggests you can do say -f script.txt -o greetings.aiff to load what should be said from script.txt and save the audio output as greetings.aiff. You can then convert it to mp3 using lame with lame -m m greetings.aiff greetings.mp3 Definitely try … Read more
PyAudiere is a simple cross-platform solution for the problem: >>> import audiere >>> d = audiere.open_device() >>> t = d.create_tone(17000) # 17 KHz >>> t.play() # non-blocking call >>> import time >>> time.sleep(5) >>> t.stop() pyaudiere.org is gone. The site and binary installers for Python 2 (debian, windows) are available via the wayback machine e.g., … Read more
kdazzle’s solution is almost there – it still output a stereo wav, here is a slightly modified version that generate mono: ffmpeg -i 111.mp3 -acodec pcm_s16le -ac 1 -ar 16000 out.wav also, if this is for pre-processing speech data for sphinx 4 see here: Convert audio files for CMU Sphinx 4 input
I maintain an open source library, pydub, which can help you out with that. from pydub import AudioSegment sound = AudioSegment.from_mp3(“/path/to/file.mp3”) sound.export(“/output/path/file.wav”, format=”wav”) One caveat: it uses ffmpeg to handle audio format conversions (except for wav files, which python handles natively). note: you probably shouldn’t do this conversion on GAE :/ even if it did … Read more
I have seen similar behavior couple times and it was related to lowering cpu frequency for power saving. If you have rooted device you can try going to: cd /sys/devices/system/cpu/ And for all cpu’s you see (replace cpuX by cpu0, cpu1 and etc) do: echo 1 > cpuX/online echo performance > cpuX/cpufreq/scaling_governor If this is … Read more