speed up mp3

I

Ivo Woltring

Dear Pythoneers,

I have a blind friend who listens a lot to audio books. A lot of the
material available today is in mp3 format.
For ages i have been looking for a mp3-player with speed control and haven't
found any.
Next option: write one yourself.
And I have ;-). with the PyMedia module.
It is an only sleightly adjusted version of one of the examples.

Now the Question:
Is it possible to re-Encode mp3 files with this faster speed as to make them
portable to e.g. Pocket PC (without python interpreter) or standard MP3
player (hardware)?

The files have to play at about 1.5 times the normal speed.

I tried it with PyMedia but I only get errors. Any help would be
appreciated.

#=============CODE==================
#! /bin/env python

import sys,os

def aplayer( name, codec='mp3', card=0, rate=1 ):
import pymedia.audio.acodec as acodec
import pymedia.audio.sound as sound
import time
try: cod=os.path.splitext(name)[ 1 ].lower()[1:]
except: cod=''
if cod: codec = cod
dec= acodec.Decoder( codec )
snds= sound.getODevices()
if card not in range( len( snds ) ):
raise 'Cannot play sound to non existent device %d out of %d' % ( card+
1, len( snds ) )
f= open( name, 'rb' )
snd= None
s= f.read( 50000 )
while len( s ):
r= dec.decode( s )
if snd== None:
print '-'*75
print 'Playing: %s' % os.path.basename(name)
print 'Opening sound with %d channels -> %s' % ( r.channels, snds[
card ][ 'name' ] )
print 'Orig sample rate: %s' % r.sample_rate
if rate<0: sr=r.sample_rate/abs(rate)
else: sr=r.sample_rate*rate
sr = int(sr)
print 'Play sample rate: %s' % sr
snd= sound.Output( sr, r.channels, sound.AFMT_S16_LE, card )
if r:
snd.play( r.data )

s= f.read( 512 )

while snd.isPlaying():
time.sleep( .05 )

# --------------------------------------------------------------------------
--------
# Play any compressed audio file
# http://pymedia.org/
if len( sys.argv )< 2 or len( sys.argv )> 3:
print "Usage: aplayer <filename> [ rate ]"
else:
i= 0
if len( sys.argv )== 3:
i= eval(sys.argv[ 2 ])
else: i=1
aplayer( sys.argv[ 1 ], rate=i )
#==================END CODE==============
 
D

Dave Brueck

Ivo said:
Dear Pythoneers,

I have a blind friend who listens a lot to audio books. A lot of the
material available today is in mp3 format.
For ages i have been looking for a mp3-player with speed control and haven't
found any.

Really? For PC playback, on Windows at least there are plugins for WinAmp to do
this, and Windows Media Player (at least version 9 at later) support this out of
the box. For MP3 devices, I know for sure at least one model from Creative
supports the faster playback - I can find the specific model if you need.

-Dave
 
I

Ivo Woltring

Thanks
No it is meant for normal devices so resampling (re-coding) is nessesary.
He doesn't want to buy special stuff to make things work.

Ivo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,701
Latest member
XavierQ83

Latest Threads

Top