#!/usr/bin/python import mad, ao, sys def play(fileName): mf = mad.MadFile(fileName) dev = ao.AudioDevice('alsa',rate=mf.samplerate()) while 1: buf = mf.read() if buf is None: break dev.play(buf, len(buf)) def on_btnSpeak_clicked(self): f=open("audio.mp3","wb") f.write(self.dic.extractAudio(self._offset, self._length)) f.close() if os.name == 'posix': import audio_linux as audio elif os.name == 'nt': import audio_windows as audio else: print "Sorry. Audio isn't supported on this platform. :)" return audio.play("audio.mp3")